Devices & Components
Arduino Uno Rev3
5 mm LED: Red
Rotary Potentiometer, 10 kohm
5 mm LED: Yellow
Resistor 330 ohm
Solderless Breadboard Full Size
Male/Male Jumper Wires
5 mm LED: Green
Software & Tools
Arduino IDE
Project description
Code
Alarm System Volatge
c_cpp
Code to this project.
1int rPin = 11 ; 2int yPin = 12 ; 3int gPin = 13 ; 4int readPin = A0; 5float Val ; 6float readVal ; 7String myString = "The Potentiometer Voltage is : " ; 8int wait = 1000; 9 10void setup() { 11 // put your setup code here, to run once: 12pinMode(rPin,OUTPUT); 13pinMode(yPin,OUTPUT); 14pinMode(gPin,OUTPUT); 15pinMode(readPin,INPUT); 16Serial.begin(9600); 17} 18void loop() { 19 // put your main code here, to run repeatedly: 20readVal = analogRead(readPin); 21Val = (5./1023.)*readVal; 22 if (Val <= 3.00) { 23 digitalWrite(gPin,HIGH); 24 digitalWrite(yPin,LOW); 25 digitalWrite(rPin,LOW); 26 } 27 if (Val < 4.00 && Val > 3.00) { 28 digitalWrite(gPin,LOW); 29 digitalWrite(yPin,HIGH); 30 digitalWrite(rPin,LOW); 31 } 32 33 if (Val > 4.00 && Val<= 6.00) { 34 digitalWrite(gPin,LOW); 35 digitalWrite(yPin,LOW); 36 digitalWrite(rPin,HIGH); 37 } 38 39 Serial.print(myString); 40 Serial.println(Val); 41delay(wait); 42} 43
Downloadable files
Voltage Led Alert
Voltage Led Alert
Voltage Led Alert
Voltage Led Alert
Comments
Only logged in users can leave comments