diff options
| author | abel <71026016+ableTI@users.noreply.github.com> | 2024-04-29 20:23:12 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-29 20:23:12 +0200 |
| commit | 0c42cdc69cb79e1866f7dd54e0f2e3bd420ad296 (patch) | |
| tree | 410b174d357bb1aba7989215da5a2782116390ed | |
| parent | 66fa9d59a3f9a6a56f1126a2d489c1ed01bd9229 (diff) | |
| download | robotica-0c42cdc69cb79e1866f7dd54e0f2e3bd420ad296.tar.gz robotica-0c42cdc69cb79e1866f7dd54e0f2e3bd420ad296.zip | |
buzz debug
| -rw-r--r-- | color_sensor/color_sensor.ino | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/color_sensor/color_sensor.ino b/color_sensor/color_sensor.ino index ab36cec..f3e9c07 100644 --- a/color_sensor/color_sensor.ino +++ b/color_sensor/color_sensor.ino @@ -21,7 +21,7 @@ color sensor based on± Adafruit_TCS34725 tcs = Adafruit_TCS34725();
//Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_614MS, TCS34725_GAIN_1X);
-const int buzzer = 9; //buzzer to arduino pin 9
+const int buzzer = 6; //buzzer to arduino pin 9
int colsensdata[6] = {99, 99, 99, 99, 99, 99};
@@ -30,7 +30,7 @@ int colsensdata[6] = {99, 99, 99, 99, 99, 99}; void setup() {
Serial.begin(115200);
- while (!Serial); // Leonardo: wait for Serial Monitor
+ //while (!Serial); // Leonardo: wait for Serial Monitor
Serial.println("\nI2C Scanner");
pinMode(buzzer, OUTPUT);
@@ -127,18 +127,22 @@ void loop() { Serial.print("RGB: "); Serial.print(r, DEC); Serial.print(", "); Serial.print(g, DEC); Serial.print(", "); Serial.print(b, DEC); Serial.println(" ");
if ((colorTemp) == 5201){
Serial.println("sensor in air");
+ tone(buzzer, 100);
colsensdata[t] = 0;
}
else if ((g)>=(2*(r)) && (g)>=12){
Serial.println("green");
+ tone(buzzer, 200);
colsensdata[t] = 1;
}
else if ((colorTemp)>= 6750){
Serial.println("black");
+ tone(buzzer, 300);
colsensdata[t] = 2;
}
else if ((colorTemp) < 6750){
Serial.println("white");
+ tone(buzzer, 400);
colsensdata[t] = 3;
}
else{
@@ -153,6 +157,7 @@ void loop() { Serial.println("No TCS34725 found ... check your connections");
colsensdata[t] = 97;
}
+ delay(500);
}
}
}
@@ -174,7 +179,5 @@ void loop() { Serial.println("");
Serial.println("DONE");
tone(buzzer, 1000);
- delay(500);
- noTone(buzzer);
- delay(5500);
+ delay(2500);
}
|
