Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int pinTEMP = A1;
- int pinIR = A2;
- int pinLIGHT = A3;
- int TEMP = 0;
- int IR = 0;
- int LIGHT = 0;
- int pinLED1 = 11;
- int pinLED2 = 10;
- int pinLED3 = 9;
- int pinS1 = 2;
- int pinS2 = 3;
- int pinS3 = 4;
- boolean S1 = false;
- boolean S2 = false;
- boolean S3 = false;
- void setup() {
- Serial.begin(9600);
- pinMode(pinLED1, OUTPUT);
- pinMode(pinLED2, OUTPUT);
- pinMode(pinLED3, OUTPUT);
- pinMode(pinS1, INPUT);
- pinMode(pinS2, INPUT);
- pinMode(pinS3, INPUT);
- }
- void loop(){
- TEMP = analogRead(pinTEMP);
- IR = analogRead(pinIR);
- LIGHT = analogRead(pinLIGHT);
- if (digitalRead(pinS1) == LOW) { S1 = !S1;}
- if (digitalRead(pinS2) == LOW) { S2 = !S2;}
- if (digitalRead(pinS3) == LOW) { S3 = !S3;}
- delay(500);
- if (S1) {
- analogWrite(pinLED1, TEMP);
- Serial.print("T");
- Serial.println(TEMP);
- } else {
- analogWrite(pinLED1, 0);
- }
- if (S2) {
- analogWrite(pinLED2, IR);
- Serial.print("I");
- Serial.println(IR);
- } else {
- analogWrite(pinLED2, 0);
- }
- if (S3) {
- analogWrite(pinLED3, LIGHT);
- Serial.print("L");
- Serial.println(LIGHT);
- } else {
- analogWrite(pinLED3, 0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement