Joystick Lantern
1304410487@qq.com(讨论 | 贡献)2015年10月20日 (二) 03:02的版本 (Created page with "{{Language| Joystick lantern}} {| style="width: 800px;" |- | ==Objective== To control the lantern's color and brightness through Joystick. ==Principle== ==Equipment== {|cla...")
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 |