Advertisement
kowalyshyn_o

CODE #3 (ISTE 2016)

Jun 21st, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. int sensorTemp;
  2.  
  3. void setup() {
  4.   Serial.begin(9600);
  5.   //set up serial port
  6.  
  7.   pinMode(10, OUTPUT);
  8.   //pin 10 is a PWM pin which can take steps from 0-255
  9.  
  10.    digitalWrite(10, LOW);
  11.   //turn LED off
  12. }
  13.  
  14. void loop() {
  15.    
  16.   sensorTemp = analogRead(A2);
  17.  
  18.   if (sensorTemp > 147) {
  19.     digitalWrite(10, HIGH);
  20.   }
  21.  
  22.   else if (sensorTemp <=147) {
  23.      digitalWrite(10, LOW);
  24.   }
  25.  
  26.   //Debug code
  27.   Serial.print("Value: ");
  28.   Serial.println(sensorTemp);
  29.   delay(100);
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement