Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int BLED=9 ;
- const int GLED=10 ;
- const int RLED=11 ;
- const int TEMP=0 ;
- const int LOWER_BOUND=146 ;
- const int UPPER_BOUND=167 ;
- int val = 0 ;
- int color=0;
- void setup ()
- {
- pinMode (BLED, OUTPUT) ;
- pinMode (GLED, OUTPUT) ;
- pinMode (RLED, OUTPUT) ;
- Serial.begin (9600) ;
- }
- void loop()
- {
- val = analogRead(TEMP) ;
- Serial.println(val);
- delay(50) ;
- if (val < LOWER_BOUND+5)
- {
- digitalWrite(RLED, LOW) ;
- digitalWrite(GLED, LOW) ;
- digitalWrite(BLED, HIGH) ;
- }
- else
- {
- color = (val-46)*1.5 ;
- analogWrite(RLED, color) ;
- analogWrite(GLED, 0) ;
- analogWrite(BLED,255-color ) ;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement