I used 3DP and arduino Nano to build the light sword.
There are 4 kind of LED blink modes.Just press buttom to change LED blink modes.
When you wave the sword, it can beep.
Step A:3DP elements
Downlaod 3DP STL file:
http://www.thingiverse.com/thing:1422473
Step B:Electronic and other material:
1.Arduino nano x1
2.LED x104
3.power switch x1
4.buttom switch x1
5.beep x1
6.virbration sensor x1.
7.18650 battery 2S
8.glue
9.Acrylic tube 1M x2
Step C:Circuit design & Arduino program.
1:Arduino source code.
Download arduino source code:
https://github.com/Ashing00/sword/tree/master
Due to arduino nano in default only have d3,d5,d6,d9,d10,d11 pin as PWM function.
In order to control the LED brightness so I made the below function to let D2-D9 pin have PWM function.
see the sample code:
//=====PWM sample code======
t3.every(2, MY_PWM);
void MY_PWM() //2ms PWM
{
LEDONOFF(PWM_PIN,PWM_T0);
}
void LEDONOFF(int pin,int t_on) //2ms PWM
{
if(t_on<=255){
for(int i=0;i<=255;i++)
{
if(i<=t_on){
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
}
else{
digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(7,LOW);
digitalWrite(8,LOW);
digitalWrite(9,LOW);
}
}
}
}
//=====PWM sample code======
2.circuit
update soon...
or you can see the source code pin define then understand how to conect
arduino nano gpio pins.
The key point:
Use 13 LED in parallel as a group then connect group 1 to D2 pin.
connect group 2 to D3 pin.
connect group 3 to D4 pin.
.......
connect group 8 to D9 pin.
then just using Arduino nano controll one LED group as one LED.
Step D:Assembe
Just reference below picture.
Be careful to weld everything.
I used the Acrylic tube to emhance the sword shell structure.
just glue the each jointer.
Another shell type:
Step E:Watch the Demo film:
加入阿布拉機的3D列印與機器人的FB粉絲團
https://www.facebook.com/arbu00/
Scan QRcode to join FB Fans page.