Day 5
For the lab i had to write a program that causes an LED to change color depending on the temperature Here's the code //Potentiometer Reading Program const int POT=0; //Pot on analog pin 0 int val = 0; //variable to hold the analog reading from the POT const int BLED=9; //Blue LED on Pin 9 const int GLED=10; //Green LED on Pin 10 const int RLED=11; //Red LED on Pin 11 int ledMode = 0; //Cycle between LED states void setup() { Serial.begin(9600); //Start Serial Communication pinMode (BLED, OUTPUT); //Set Blue LED as Output pinMode (GLED, OUTPUT); //Set Green LED as Output pinMode (RLED, OUTPUT); //Set Red LED as Output } void loop() { val = analogRead(POT); //Read one value from the POT if (val <= 139) { digitalWrite(BLED,HIGH); digitalWrite(GLED,LOW); digitalWrite(RLED,LOW); } if (val<=147 && val>=139) { digitalWrite(GLED,HIGH); digitalWrite(BLED,LOW); digitalWrite(RLED,...




Comments
Post a Comment