Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Include application, user and local libraries
- #include "LCD_Launchpad.h"
- LCD_LAUNCHPAD myLCD;
- const int buttonPin1 = PUSH1;
- const int buttonPin2 = PUSH2;
- int buttonState1 = 0;
- int buttonState2 = 0;
- void setup() {
- // initialize serial communications (for debugging only):
- Serial.begin(9600);
- myLCD.init();
- pinMode(buttonPin1, INPUT_PULLUP);
- pinMode(buttonPin2, INPUT_PULLUP);
- }
- void loop() {
- // read the sensor:
- int sensorReading = analogRead(A9);
- // print the sensor reading so you know its range
- Serial.println(sensorReading);
- // map the pitch to the range of the analog input.
- // change the minimum and maximum input numbers below
- // depending on the range your sensor's giving:
- int thisPitch = map(sensorReading, 20, 10000, 80, 11000);
- // play the pitch:
- tone(9, thisPitch);
- myLCD.clear();
- myLCD.showSymbol(LCD_SEG_RADIO, 1);
- myLCD.println(thisPitch + 2);
- myLCD.print("Hz ");
- buttonState1 = digitalRead(buttonPin1);
- if (buttonState1 == LOW) {
- // turn delay on:
- delay(50);
- }
- buttonState2 = digitalRead(buttonPin2);
- if (buttonState2 == LOW) {
- // turn delay on:
- delay(200);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement