Created
December 1, 2019 21:02
-
-
Save user0able/9087acfca83c30fd21547db710f788c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @author Ernesto Muñoz | |
int redPin=9; | |
int greenPin=10; | |
int bluePin=11; | |
int buzzerPin=7; | |
int potPin=1; | |
int sensorPin=0; | |
int red = 1; | |
int green = 2; | |
int blue = 3; | |
int band =15; | |
void setup() | |
{ | |
pinMode(potPin, INPUT); | |
pinMode(sensorPin, INPUT); | |
pinMode(redPin, OUTPUT); | |
pinMode(greenPin, OUTPUT); | |
pinMode(bluePin, OUTPUT); | |
pinMode(buzzerPin, OUTPUT); | |
Serial.begin(9600); | |
} | |
void loop() | |
{ | |
int gsr = analogRead(sensorPin); | |
int pot = analogRead(potPin); | |
Serial.print("Pot: "); //Imprime en el monitor serial el valor del potenciometro | |
Serial.print(pot); | |
Serial.print(" Sensor Input: "); // Medicicion de la resistencia de la persona | |
Serial.print(gsr); | |
Serial.print(" LED: "); // Indica el LED que debe estar encendido | |
if (gsr > (pot + band)) | |
Serial.println("RED"); | |
else if (gsr < (pot - band)) | |
Serial.println("BLUE"); | |
else | |
Serial.println("GREEN"); | |
delay(500); | |
if (gsr > pot + band) | |
{ | |
beep(); | |
digitalWrite(redPin, HIGH); | |
digitalWrite(greenPin, LOW); | |
digitalWrite(bluePin, LOW); | |
} | |
else if (gsr < pot - band) | |
{ | |
digitalWrite(bluePin, HIGH); | |
digitalWrite(redPin, LOW); | |
digitalWrite(greenPin, LOW); | |
} | |
else | |
{ | |
digitalWrite(greenPin, HIGH); | |
digitalWrite(bluePin, LOW); | |
digitalWrite(redPin, LOW); | |
} | |
} | |
void beep() | |
{ | |
for (int i = 0; i < 1000; i++) | |
{ | |
digitalWrite(buzzerPin, HIGH); | |
delayMicroseconds(100); | |
digitalWrite(buzzerPin, LOW); | |
delayMicroseconds(100); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment