Hello there! I am trying to find a way to code on how to activate or deactivate buzzers when the RGB sensor detects a high or low value on the chosen color as you have read on what this discussion will be about.
I am just new to coding so I have little to no knowledge on how to program these types of sensors because my school suddenly decided to add Robotics as our additional subject and only taught us how to make an LED light and how to activate a buzzer then told us to build an Arduino project without teaching us anything other than what I previously mentioned and we can't ask our upperclassmen for help because they didn't have Robotics as their additional subject before moving up.
This project is worth 100% of my grades so if I can't pass it to my professor before the exams I will not be able to graduate so even though this might sound ridiculous to others it is what my current state is and I can't find any helpful tips or videos online or I might not be looking hard enough so any help or advice would be really, really helpful to me. Thanks in advance
Well It means the teachers want to appreciate your ability to learn by yourself and build a path were you can succeed in the project. It's like in real life...
I would suggest you write a small sketch printing out the color your read from the sensor (which sensor?)
then modify this code so that it only prints something of interest
then replace the printing by the buzzer with the tone function
Thanks for the suggestion but the only problem is my professor never really taught us some basic knowledge let alone how to modify codings that I had to look up what "sketch" means on google ( they really did just throw the project at our faces that we had to rely on youtube videos on how to get things done and i might not have mentioned this but the school I go to is in the Philippines and I go to school in 6 A.M and go home at 5 A.M and have chores to do so its hard to find time to work on this project).
hope you have less than 1h of chores duty...
Whilst I can relate to the situation (mine was worse), there is always time if you decide something has to be a priority - and you are young, you can sleep later
the task was given about a month ago when we came back to school on January 3.
It was the time where drawing some ideas and what should I make at that time since I didn't think it would be difficult seeing as how we were given a month and thought that my professor would teach us but after submitting the final drawing I slowly woke up to the harsh reality of Robotics because we had many events in our school last month. The whole school became busy with preparations for a municipal meet held at our highschool where 11 schools came in to compete in sports.
hello, sorry for the late reply
the sensor that I am using is an APDS-9960 RGB/Gesture sensor and I already have the coding for it from watching youtube videos but I have yet to solder the sensor to the berg strip it came with.
here is the coding that I used and as for the products, I did not order them online because I asked my cousin to buy the products I am needed in Manila but I will find links with similar products. Also i do not know how to draw a schematic diagram
/****************************************************************
ColorSensor.ino
APDS-9960 RGB and Gesture Sensor
Shawn Hymel @ SparkFun Electronics
October 15, 2014
https://github.com/sparkfun/APDS-9960_RGB_and_Gesture_Sensor
Tests the color and ambient light sensing abilities of the
APDS-9960. Configures APDS-9960 over I2C and polls the sensor for
ambient light and color levels, which are displayed over the
serial console.
Hardware Connections:
IMPORTANT: The APDS-9960 can only accept 3.3V!
Arduino Pin APDS-9960 Board Function
3.3V VCC Power
GND GND Ground
A4 SDA I2C Data
A5 SCL I2C Clock
Resources:
Include Wire.h and SparkFun_APDS-9960.h
Development environment specifics:
Written in Arduino 1.0.5
Tested with SparkFun Arduino Pro Mini 3.3V
This code is beerware; if you see me (or any other SparkFun
employee) at the local, and you've found our code helpful, please
buy us a round!
Distributed as-is; no warranty is given.
****************************************************************/
#include <Wire.h>
#include <SparkFun_APDS9960.h>
// Global Variables
SparkFun_APDS9960 apds = SparkFun_APDS9960();
uint16_t ambient_light = 0;
uint16_t red_light = 0;
uint16_t green_light = 0;
uint16_t blue_light = 0;
void setup() {
// Initialize Serial port
Serial.begin(9600);
Serial.println();
Serial.println(F("--------------------------------"));
Serial.println(F("SparkFun APDS-9960 - ColorSensor"));
Serial.println(F("--------------------------------"));
// Initialize APDS-9960 (configure I2C and initial values)
if ( apds.init() ) {
Serial.println(F("APDS-9960 initialization complete"));
} else {
Serial.println(F("Something went wrong during APDS-9960 init!"));
}
// Start running the APDS-9960 light sensor (no interrupts)
if ( apds.enableLightSensor(false) ) {
Serial.println(F("Light sensor is now running"));
} else {
Serial.println(F("Something went wrong during light sensor init!"));
}
// Wait for initialization and calibration to finish
delay(500);
}
void loop() {
// Read the light levels (ambient, red, green, blue)
if ( !apds.readAmbientLight(ambient_light) ||
!apds.readRedLight(red_light) ||
!apds.readGreenLight(green_light) ||
!apds.readBlueLight(blue_light) ) {
Serial.println("Error reading light values");
} else {
Serial.print("Ambient: ");
Serial.print(ambient_light);
Serial.print(" Red: ");
Serial.print(red_light);
Serial.print(" Green: ");
Serial.print(green_light);
Serial.print(" Blue: ");
Serial.println(blue_light);
}
// Wait 1 second before next reading
delay(1000);
}
there is no problem with the circuitry, the problem is that I do not know how or what to add to the coding in order for the buzzer to activate when one or more colors have reached the certain degree that was set up. To put it simply, i do not know how to use the variables and functions in coding
Generally we were never really taught how to code in arduino.IDE because the professor only told us to copy the sketch he showed us on his laptop without ever really explaining the uses of variables like int, pinMode or digitalWrite were.
I encourage you to show this to your "professor" (send a link to your professor).
I highly doubt your claim, but if true, your problem is not about having other people create and complete your project, but informing your education administrators of your claims against your professor.