Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // include the library code:
- #include <LiquidCrystal.h>
- int sensorPin = A0; // select the input pin for the potentiometer
- int ledPin = 9; // select the pin for the LED
- // Pin 13: Arduino has an LED connected on pin 13
- // Pin 11: Teensy 2.0 has the LED on pin 11
- // Pin 6: Teensy++ 2.0 has the LED on pin 6
- int sensorValue = 0; // variable to store the value coming from the sensor
- // initialize the library with the numbers of the interface pins
- LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
- void setup() {
- // declare the ledPin as an OUTPUT:
- pinMode(ledPin, OUTPUT);
- // set up the LCD's number of columns and rows:
- lcd.begin(16, 2);
- // Print a message to the LCD.
- lcd.print("hello, world!");
- lcd.display();
- }
- void loop() {
- // read the value from the sensor:
- sensorValue = analogRead(sensorPin);
- lcd.clear();
- lcd.print(sensorValue);
- // turn the ledPin on
- digitalWrite(ledPin, HIGH);
- // stop the program for <sensorValue> milliseconds:
- delay(sensorValue);
- // turn the ledPin off:
- digitalWrite(ledPin, LOW);
- // stop the program for for <sensorValue> milliseconds:
- delay(sensorValue);
- }
Advertisement
Add Comment
Please, Sign In to add comment