awinograd

EE 47 - Lab 3 - "Multimeter"

Apr 25th, 2012
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.19 KB | None | 0 0
  1. // include the library code:
  2. #include <LiquidCrystal.h>
  3.  
  4. int sensorPin = A0;    // select the input pin for the potentiometer
  5. int ledPin = 9;      // select the pin for the LED
  6.   // Pin 13: Arduino has an LED connected on pin 13
  7.   // Pin 11: Teensy 2.0 has the LED on pin 11
  8.   // Pin 6: Teensy++ 2.0 has the LED on pin 6
  9. int sensorValue = 0;  // variable to store the value coming from the sensor
  10.  
  11. // initialize the library with the numbers of the interface pins
  12. LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
  13.  
  14. void setup() {
  15.   // declare the ledPin as an OUTPUT:
  16.   pinMode(ledPin, OUTPUT);  
  17.   // set up the LCD's number of columns and rows:
  18.   lcd.begin(16, 2);
  19.   // Print a message to the LCD.
  20.   lcd.print("hello, world!");  
  21.   lcd.display();
  22. }
  23.  
  24. void loop() {
  25.   // read the value from the sensor:
  26.   sensorValue = analogRead(sensorPin);
  27.   lcd.clear();
  28.   lcd.print(sensorValue);    
  29.   // turn the ledPin on
  30.   digitalWrite(ledPin, HIGH);  
  31.   // stop the program for <sensorValue> milliseconds:
  32.   delay(sensorValue);          
  33.   // turn the ledPin off:        
  34.   digitalWrite(ledPin, LOW);  
  35.   // stop the program for for <sensorValue> milliseconds:
  36.   delay(sensorValue);                  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment