Wiichuck Controlled Laser and Dual ServoMotor Turret By: Ryan Goyette and Nick Ferrara Our project is a wiichuck controlling a servo(vertical) and another servo (horizontal) and a laser at the same time. The objective of this is to control it with percision. #include <Wire.h> void setup()
nunchuck_get_data(); Serial.print("joyx: "); Serial.print((byte)joyx,DEC); // print variable values accx = nunchuck_accelx(); // ranges from approx 70 - 182 accy = nunchuck_accely(); // ranges from approx 65 - 173 zbut = nunchuck_zbutton(); cbut = nunchuck_cbutton(); Serial.print("accx: "); Serial.print((byte)accx,DEC); Serial.print("\taccy: "); Serial.print((byte)accy,DEC); Serial.print("\tzbut: "); Serial.print((byte)zbut,DEC); Serial.print("\tcbut: "); Serial.println((byte)cbut,DEC); if(joyx>130&&angle>0) { angle=angle+1; } if(joyx<120&&angle<180) { angle=angle-1; } if(joyy>135&&angley>0) { angley=angley-1; } if(joyy<120&&angley<180) { angley=angley+1; } } myservo.write(angle); if (zbut==1) {digitalWrite(7, HIGH); // this turns the laser on by pressing "z" } else { digitalWrite(7, LOW); } myservo2.write(angley); loop_cnt++; } We encountered problems with the servos twitching. We resolved that by increasing the Range of joyx and joyy to +-5. If we had more time/resources we would want to hook up a speaker to make laser noises And also add another laser. |
Electronics Class > Electronics Fall 2011 >