An Arduino Uno board hooked up to a servo motor, LCD display, a color sensor, photoresistor, button, and a red LED. G
Close up to LED measurer. G
Close up to button on breadboard. G
Testing color sensor to LED blink rate to servo. Also testing the skip the middle-man button, i.e., color to servo. G
The device reads the brightness of the room, then converts that signal into an LED blink rate. The device then interprets that LED blink rate by reading brightness changes and maps that change time to an angle for which the servo motor will move to. Using a button on the bread board, you can skip the LED blink rate section entirely and instead map brightness to and a servo angle directly. The LCD shows the RGB values as well as the LED blink time as needed. (G)
Soldering failure #1 G
LED blink rate testing. G
The most difficult part was simply soldering. I failed miserably twice soldering my boards and had spent the most amount of time on it. Writing the code and wiring everything else took only two-to-three hours, not including the LCD needing to be screwed, that added two hours on its own. Overall I found the most of the project straight forward, but as I expected I am a failure when it comes to building physical structures.
I cannot say I spent time with my partner, as we never needed to --- other than agreeing on what we would do. This is my preferred way, and I was quite happy with the arrangement. Overall, I show no improvement at soldering and no signs of ever improving, but I found it fun. I am willing to believe that I will not ever improve at this, as I tend to always be awful at this sort of work.
As for as creative and technical growth, I cannot say I saw any creative growth in the slightest. That being said, I found my wiring becoming quicker and quicker as I kept accidentally unplugging. I also improved at using the ioref website to find the appropriate resistors and so on. As such, I feel confident to build anything similar again. G
Discussion (one per team) pertaining to process and outcome. For instance, what was easy, what was hard, what did you learn? What little tweak, in retrospect, would’ve changed the direction entirely? This is an opportunity for you to reflect on your creative and technical growth through the project, and think about what growth you want to aim for next. This shouldn’t be a recital of your process, but rather a meaningful reflection, 3–4 paragraphs in length. Reminder: do not use any generative AI to help write this section.
Electrical scheme (top) and functional block diagram (bottom). G
/* Arduino Uno Double Transducer project thing
Code by G
The code reads a color sensor's brightness, then transmits that linearly to an LED's blink rate. This is then measured by a photoresistor and translated linearly to a servo motor. There is a button that will skip the LED blink rate portion and jump to the servo motor from the color.
*/
/*
Device - Pin(s)
APDS-9960 - A0 A1 1 (3.3v)
Servo - 7
LED - 13
Button - 12
Photo - A3
LCD - SDA SVA
*/
#include <Adafruit_APDS9960.h>
#include <Servo.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
// Input/Output listeners defined > partial at times
const static uint16_t SWITCH_PIN = 12;
const static uint16_t LED_PIN = 13;
const static uint16_t PHOTO_PIN = A3;
const static uint16_t SERVO_PIN = 7;
static Adafruit_APDS9960 apds;
Servo servo;
static uint16_t r0,g0,b0,r,g,b,c;
static uint16_t lightVal, oldLightVal;
static uint32_t lightBlinkTime = 0;
LiquidCrystal_I2C screen(0x27,16,2);
static uint16_t servoVal;
static uint32_t lastUpdateTime = 0;
const static uint32_t UPDATE_TIME = 200;
void setup() {
screen.init();
screen.backlight();
screen.clear();
pinMode (SWITCH_PIN, INPUT);
pinMode (PHOTO_PIN, INPUT);
pinMode (LED_PIN, OUTPUT);
servo.attach(SERVO_PIN);
Serial.begin(9600);
if (!apds.begin())
Serial.println("Error initializing APDS9960 sensor!");
apds.enableColor(true);
servo.attach(SERVO_PIN);
// Initializing values
r0 = 0;
g0 = 0;
b0 = 0;
r = 0;
g = 0;
b = 0;
}
void loop() {
updateColorData();
if (digitalRead (SWITCH_PIN) == LOW){
colorToLight ();
lightToServo ();
}
else
colorToServo ();
}
void colorToLight (){
uint16_t blinkTime = map ((r+g+b)/3 % 255,0,255,150,405);
LEDBlink (blinkTime % 406);
}
void lightToServo (){
servoVal = map(lightBlinkTime,150, 405,10, 170);
servo.write(servoVal);
}
void updateColorData() {
while (!apds.colorDataReady())
delay (5);
r0 = r;
b0 = b;
g0 = g;
apds.getColorData(&r, &g, &b, &c);
LCDDataUpdate ();
}
void LEDBlink(uint16_t time){
uint16_t timeCheck = 7;
uint16_t holdTime = 0;
lightBlinkTime = 0;
oldLightVal = analogRead (PHOTO_PIN);
digitalWrite (LED_PIN, HIGH);
while (holdTime < time){
holdTime += timeCheck;
if (analogRead (PHOTO_PIN) > oldLightVal + 80){
lightBlinkTime += timeCheck;
}
LCDDataUpdate();
delay (timeCheck);
}
digitalWrite (LED_PIN, LOW);
delay (time/2);
}
void colorToServo(){
// x is a smoothed transition value
uint16_t x = (r + r0 + g + g0 + b + b0) / 6 % 255;
servoVal = map (x, 0,255, 10,170);
servo.write(servoVal);
LCDDataUpdate();
delay (100);
LCDDataUpdate();
}
void LCDDataUpdate (){
if (millis() - lastUpdateTime > UPDATE_TIME){
lastUpdateTime = millis();
screen.clear();
screen.setCursor (0,0);
screen.print("RGB ");
screen.print(r % 255);
screen.print(" ");
screen.print(g % 255);
screen.print(" ");
screen.print(b % 255);
screen.setCursor (0,1);
if (digitalRead (SWITCH_PIN) == LOW){
screen.print("LBT ");
screen.print(lightBlinkTime);
}
else{
screen.print("Servo Angle ");
screen.print(servoVal);
}
}
}