Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <LiquidCrystal.h>
- #include <String.h>
- int temp_pin = 0;
- int light_pin = 1;
- int data_write_offset = 6;
- // BS E D4 D5 D6 D7
- LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
- void setup() {
- Serial.begin( 9600 );
- lcd.begin( 16, 2 );
- }
- void loop() {
- uint32_t temp_reading;
- for (uint8_t x = 0; x < 100; x++) { // take 100 readings
- temp_reading = analogRead( temp_pin )
- }
- temp_reading = temp_reading / 100;
- Serial.println( temp_reading );
- float temp_volts = temp_reading * 5.0 / 1024.0;
- float temp_c = (temp_volts - 0.5) * 100.0;
- float temp_f = temp_c * 9.0 / 5.0 + 32.0;
- lcd.clear();
- lcd.setCursor(0,0);
- lcd.print("Temp");
- for( int i = 0; i < data_write_offset - strlen("Temp"); i++ )
- lcd.print(" ");
- lcd.print( temp_c );
- lcd.print(" C");
- int light_reading = analogRead( light_pin );
- lcd.setCursor(0,1);
- lcd.print("Light");
- for( int i = 0; i < data_write_offset - strlen("Temp"); i++ )
- lcd.print(" ");
- lcd.print( light_reading );
- delay( 500 );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement