Joystick Lantern
Language | English |
---|
ObjectiveTo control the lantern's color and brightness through Joystick. PrincipleEquipment
Hardware Buildup
Software DebuggingCode Description
#define JoystickX_PIN A1
#define JoystickY_PIN A0
if (sensorValueY <= 10)
{
delay(500);
num++;
if (num > 8)
num = 0;
}
else if (sensorValueY > 800)
{
delay(500);
num--;
if (num < 0)
num = 8;
}
if (sensorValueX <= 10)
{
delay(10);
color_l++;
if (color_l > 255)
color_l = 255;
}
else if (sensorValueX > 800)
{
delay(10);
color_l--;
if (color_l < 0)
color_l = 0;
}
colorWipe(strip.Color(map(color_l, val_min, val_max, 0, color_m[num][0]), map(color_l, val_min, val_max, 0, color_m[num][1]), map(color_l, val_min, val_max, 0, color_m[num][2])));
ResultChoose color on the X-axis and brightness on the Y-axis. You can also build a beautiful shell with LEGO. Video |