Welcome to Laser Pointer Forums - discuss green laser pointers, blue laser pointers, and all types of lasers



Laser Pointer Store

arduino powered spirograph

frostin

New member
Joined
Jul 26, 2009
Messages
70
Likes
5
Points
0

Thanks AP Digital for the mirrors, motors, and box.
Instead of a PIC based I decided to go with an arduino based.
Made my own board, used an h bridge for 3 motors and like ap digital I added a button for manual / automatic mode.
Like I said thanks AP Digital for my inspirement ;).
 
Last edited:

HaloBlu

New member
Joined
Dec 27, 2009
Messages
1,327
Likes
40
Points
0
Nice spiro. :D You just used an ATMega without a full arduino board right? ATMega328 or 168?
I demand pics of inside the box!!... I mean I politely demand? :san:

I've been thinking of trying electromagnet based tilting mirrors controlled by an ATMega328. Tho I don't know when I might have the time really.
 
Last edited:

frostin

New member
Joined
Jul 26, 2009
Messages
70
Likes
5
Points
0
Yes I used an atmega328 which I burned the arduino bootloader onto with lady ada's usb tiny avr programmer. I made my own board. If you need the .brd file let me know ;). I use eagle, what I do then is make a negative on eagle save it as a .ps file and open it up in gsview. From gsview I then print onto overhead projector paper. Then I take a copper clad board, laminate it with a negative film i got off ebay (about 20 bux for a roll), then I place it into my uv light box I made with 168 uv leds (yes alot of soldering that day). After that I develop the board, drill holes, place it in my etching tank with a mix of muratic acid and hydrogen peroxide. After that I lay the board in some drain cleaner and it lifts the film off the board.

Parts List:
Atmega 328 (burned with arduino bootloader via usbtiny avr programmer)
2x leds (one for power light, one for pin13)
1x .1uf capacitor (used for auto reset feature when pluggin in a ftdi cable)
2x lm7805,
2x 220 ohm resistors,
2x 100uf capacitors,
1x 10uf capacitors,
2x heatsinks,
1x sn754410 h bridge (motor control)
2x 10k ohm potentiometers (one for programming port, one for pushbutton)
several female & male header pins,
3x 5v dc fan motors with mirrors mounted from ap digital,
1x case from ap digital,
3x pot knobs,
1x toggle switch,
1x pushbutton,
1x power jack,
1x 3-9v 1a dc adapter
my camera doesnt pick it up too well cuz of the blue ray diode ;P
diode out of a phr803t i harvested that i fitting inside an aixiz module with a rckstr laser driver
 
Last edited:
Joined
Aug 28, 2009
Messages
1,071
Likes
59
Points
0
Nice project. I plan on making my own Spiro. soon. Just need to bone up a little more on the technicals.
 
Joined
Jul 4, 2008
Messages
2,138
Likes
35
Points
0
Very nice! I like to do my arduino spiros by using NPN and a transistor, so the NPN goes through the transistor and then I filter it with a capacitor between the legs of the motor. This prevents the problem of an oversensitive transistor giving full power to the motor no matter what PWM you're on, and the only parts you need are a motor, transistor, motor power source and of course arduino. A capacitor is optional to eliminate "whine". Then I just control it with some pots and map the analog pins to some of the PWM pins.
 
Joined
Nov 10, 2008
Messages
4,241
Likes
172
Points
0
god damn thats freaking awesome. Arduinos are very handy! +1
I might make my own version! Is this hard to build? Also, where did you buy the parts?
 
Last edited:

frostin

New member
Joined
Jul 26, 2009
Messages
70
Likes
5
Points
0
I got alot from radioshack, and rest of internet.
heres my code:

const int switchPin = 2; // switch connected to digital pin 2
int pot1 = 0; // pot1 connected to analog 0
int pot2 = 1; // pot2 connected to analog 1
int pot3 = 2; // pot3 connected to analog 2
int val1 = 0;
int val2 = 0;
int val3 = 0;
int motor1Pin = 5; // h bridge pin connected digital 5
int motor2Pin = 6; // h bridge pin connected to digital 6
int motor3Pin = 10; // hbridge pin connected to digital 10
int enablePin = 9; //h bridge enable pin connected to digital 9
int enablePin1 = 12; // hbridge enable pin connected to digital 12


void setup()
{
Serial.begin(9600);
pinMode(switchPin, INPUT);
pinMode(motor1Pin, OUTPUT);
pinMode(motor2Pin, OUTPUT);
pinMode(enablePin, OUTPUT);
digitalWrite(enablePin, HIGH);
digitalWrite(enablePin1, HIGH);






}
void loop()
{
if (digitalRead(switchPin) == HIGH) {
val1 = analogRead(pot1);
val1 = map(val1, 0, 1023, 0, 255);
analogWrite(motor1Pin, val1);
Serial.print(val1);
Serial.print(" Motor 1: ");

val2 = analogRead(pot2);
val2 = map(val2, 0, 1023, 0, 255);
analogWrite(motor2Pin, val2);
Serial.print(val2);
Serial.print(" Motor 2: ");

val3 = analogRead(pot3);
val3 = map(val3, 0, 1023, 0, 255);
analogWrite(motor3Pin, val3);
Serial.println(val3);
Serial.print(" Motor 3: ");
}
else {
delay(1000);
analogWrite(motor1Pin, 100);
delay(2000);
analogWrite(motor1Pin, 124);
delay(2000);
analogWrite(motor2Pin, 100);
analogWrite(motor2Pin, 200);
analogWrite(motor3Pin, 155);
delay(2000);
analogWrite(motor1Pin, 200);
analogWrite(motor3Pin, 0);
analogWrite(motor2Pin, 167);
delay(2000);
analogWrite(motor3Pin, 0);
analogWrite(motor2Pin, 130);
analogWrite(motor1Pin, 180);
delay (2000);
analogWrite(motor3Pin, 109);
analogWrite(motor1Pin, 190);
analogWrite(motor2Pin, 205);
delay (2000);
analogWrite(motor1Pin, 115);
delay (100);
analogWrite(motor3Pin, 160);
analogWrite(motor1Pin, 0);
analogWrite(motor3Pin, 135);
delay (2000);
analogWrite(motor3Pin, 140);
analogWrite(motor2Pin, 200);
analogWrite(motor1Pin, 190);
delay (2000);
analogWrite(motor1Pin, 100);
analogWrite(motor2Pin, 0);
analogWrite(motor3Pin, 0);
delay(100);
analogWrite(motor2Pin, 152);
analogWrite(motor1Pin, 0);
analogWrite(motor3Pin, 115);
delay(100);
analogWrite(motor1Pin, 199);
analogWrite(motor2Pin, 140);
analogWrite(motor3Pin, 178);
delay(2000);
analogWrite(motor3Pin, 100);
analogWrite(motor1Pin, 0);
analogWrite(motor2Pin, 0);
delay(100);
analogWrite(motor1Pin, 240);
analogWrite(motor2Pin, 200);
analogWrite(motor3Pin, 120);
delay(2000);
analogWrite(motor1Pin, 170);
delay(100);
analogWrite(motor2Pin, 200);
analogWrite(motor3Pin, 130);
delay(2000);
analogWrite(motor1Pin, 0);
analogWrite(motor2Pin, 0);
analogWrite(motor3Pin, 0);
delay(100);
analogWrite(motor3Pin, 105);
analogWrite(motor2Pin, 105);
analogWrite(motor1Pin, 235);
delay(2000);

}
}


Now say If I get a certain affect with the state of the pots, I can read that value and implement it in the else {
.
Now i completely understand PWM.
Total cost I'm going to say about 100 bucks give or take alot I had
I bought my atmega chips for like 3 bux a piece
the box with motors from ap digital was 50
phr803t sled was 13
rckstr driver was like what 15?
aixiz module was like 5 bucks
roughly around 100 to build
an RGV version will be my next version if I can fit a board with relays etc to switch on/off the rgb lasers.
I still have enough PWM pins for upgrades... If I wanted I still could add another mirror/motor/pot.
So, thatd be 4 motors and mirrors with 4 pots ;)

Eagle Layout:
 
Last edited:

frostin

New member
Joined
Jul 26, 2009
Messages
70
Likes
5
Points
0
You could add ANOTHER hbridge so you could do bi-directional of the motors ;) (adding more switch pins to a digital pin thats non PWM to go backwards etc)
Currently they only go one way but hey the effects are cool!

Youll need an ftdi cable to program the microcontroller... I use a sparkfun 5v ftdi basic with mini usb connector
BTW dont forgot tghe .1uf cap it lets you reprogram without holding down the reset pushbutton.
 
Last edited:
Joined
Jul 4, 2008
Messages
2,138
Likes
35
Points
0
^looks good. And I assume the long segment is just to give a random appearing pattern? Well, I have to go check if arduino supports this, but you might want to try
int randnum;
randnum = random(256);
analogWrite(motorXPin, random);

this will set the motor pin to a random 8 bit PWM integer. I don't know if you have to get an additional library to do this, I'm gonna go check.

EDIT:
You could add ANOTHER hbridge so you could do bi-directional of the motors ;) (adding more switch pins to a digital pin thats non PWM to go backwards etc)
Currently they only go one way but hey the effects are cool!

Youll need an ftdi cable to program the microcontroller... I use a sparkfun 5v ftdi basic with mini usb connector
BTW dont forgot tghe .1uf cap it lets you reprogram without holding down the reset pushbutton.
Well, there are 6 PWM pins, right? So do it like this:
Let's say pins 9 and 10 are controlling 1 motor through the h-bridge. If you want to go one way, do:
digitalWrite(9, LOW);
digitalWrite(10, pwmvalue);
and to go the other way
digitalWrite(10, LOW);
digitalWrite(9, pwmvalue);

this gives you bi-directional w/speed control on a single h-bridge.

second EDIT:
random() appears to work.
 
Last edited:

frostin

New member
Joined
Jul 26, 2009
Messages
70
Likes
5
Points
0
Correct. 0ne hbridge can do 2 bidirectional motors. Or 4 one way direction motors. I use sn754410 h bridge.
 




Top