Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int led1 = 3;
- int led2 = 4;
- int led3 = 5;
- int led4 = 6;
- int led5 = 7;
- int led6 = 8;
- int led7 = 9;
- int led8 = 10;
- int BUZZER = 2; // buzzer addressed to the pin 2
- void setup() {
- // initialize serial communication at 9600 bits per second:
- pinMode(led1, OUTPUT);
- pinMode(led2, OUTPUT);
- pinMode(led3, OUTPUT);
- pinMode(led4, OUTPUT);
- pinMode(led5, OUTPUT);
- pinMode(led6, OUTPUT);
- pinMode(led7, OUTPUT);
- pinMode(led8, OUTPUT);
- pinMode(BUZZER, OUTPUT);
- Serial.begin(9600);
- }
- void loop() {
- // read the input on analog pin 1:
- int sensorValue1 = analogRead(A0);
- if (sensorValue1 >=600 && sensorValue1 <=800){
- Serial.println(sensorValue1);
- digitalWrite(led1, HIGH);
- tone(2,392,300); //command tone that creates a sound
- }
- else {
- Serial.println(sensorValue1);
- digitalWrite(led1, LOW);
- }
- int sensorValue2 = analogRead(A1);
- if (sensorValue2 >=600 && sensorValue2 <=800){
- Serial.println(sensorValue2);
- digitalWrite(led2, HIGH);
- tone(2,392,300); //command tone that creates a sound
- }
- else {
- Serial.println(sensorValue2);
- digitalWrite(led2, LOW);
- }
- int sensorValue3 = analogRead(A2);
- if (sensorValue3 >=600 && sensorValue3 <=800){
- Serial.println(sensorValue3);
- digitalWrite(led3, HIGH);
- tone(2,392,300); //command tone that creates a sound
- }
- else {
- Serial.println(sensorValue3);
- digitalWrite(led3, LOW);
- }
- int sensorValue4 = analogRead(A3);
- if (sensorValue4 >=600 && sensorValue4 <=800){
- Serial.println(sensorValue4);
- digitalWrite(led4, HIGH);
- tone(2,392,300); //command tone that creates a sound
- }
- else {
- Serial.println(sensorValue4);
- digitalWrite(led4, LOW);
- }
- int sensorValue5 = analogRead(A4);
- if (sensorValue5 >=600 && sensorValue5 <=800){
- Serial.println(sensorValue5);
- digitalWrite(led5, HIGH);
- tone(2,392,300); //command tone that creates a sound
- }
- else {
- Serial.println(sensorValue5);
- digitalWrite(led5, LOW);
- }
- int sensorValue6 = analogRead(A5);
- if (sensorValue6 >=600 && sensorValue6 <=800){
- Serial.println(sensorValue6);
- digitalWrite(led6, HIGH);
- tone(2,392,300); //command tone that creates a sound
- }
- else {
- Serial.println(sensorValue6);
- digitalWrite(led6, LOW);
- }
- int sensorValue7 = analogRead(A6);
- if (sensorValue7 >=600 && sensorValue7 <=800){
- Serial.println(sensorValue7);
- digitalWrite(led7, HIGH);
- tone(2,392,300); //command tone that creates a sound
- }
- else {
- Serial.println(sensorValue7);
- digitalWrite(led7, LOW);
- }
- int sensorValue8 = analogRead(A7);
- if (sensorValue8 >=600 && sensorValue8 <=800){
- Serial.println(sensorValue8);
- digitalWrite(led8, HIGH);
- tone(2,392,300); //command tone that creates a sound
- }
- else {
- Serial.println(sensorValue8);
- digitalWrite(led8, LOW);
- }
- delay(1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement