Hi Guys and Girls,
As you may have noticed I am new to this forum.
I am also only a very basic programmer. Are there any tips any of you can give for me to become a better programmer? I am still in High School so I don’t have quite as much time on my hands as I would like to but I do still have enough time to work on some Arduino projects.
I have come up with an idea or two but I don’t know how to put these into code (any tips?). If any of you could give me a hand it would be much appreciated.
I would like to make a program to go with my laser tripwire that I have built using just normal electronic components which works quite well, the laser is built into this part of it so I can’t just move the laser separately to point onto the photo resistor. If any of you don't understand how a laser tripwire works please ask. Please look at attached picture as to what I want to do. I am not sure how to make all of these things work together. If I can I want to move the servo only one degree when a button is pressed.
Thanks heaps in advance,
nathman1
I'm sorry, but my crystal ball has crashed, so I can't see your code. If you post that code, between code tags (the # button above the smileys) here, maybe someone could tell you where you've gone wrong or what you need. Until you do, we can only make uninformed guesses that waste our time and yours.
Some servo test code for incremental servo movement.
// zoomkat 3-28-14 serial servo incremental test code
// using serial monitor type a character (s to increase or a
// to decrease) and enter to change servo position
// use strings like 90x or 1500x for new servo position
// for IDE 1.0.5 and later
// Powering a servo from the arduino usually *DOES NOT WORK*.
#include<Servo.h>
String readString;
Servo myservo;
int pos=1500; //~neutral value for continous rotation servo
//int pos=90;
void setup()
{
myservo.attach(7, 400, 2600); //servo control pin, and range if desired
Serial.begin(9600);
Serial.println("serial servo incremental test code");
Serial.println("type a character (s to increase or a to decrease)");
Serial.println("and enter to change servo position");
Serial.println("use strings like 90x or 1500x for new servo position");
Serial.println();
}
void loop()
{
while (Serial.available()) {
char c = Serial.read(); //gets one byte from serial buffer
readString += c; //makes the string readString
delay(2); //slow looping to allow buffer to fill with next character
}
if (readString.length() >0) {
if(readString.indexOf('x') >0) {
pos = readString.toInt();
}
if(readString =="a"){
(pos=pos-1); //use larger numbers for larger increments
if(pos<0) (pos=0); //prevent negative number
}
if (readString =="s"){
(pos=pos+1);
}
if(pos >= 400) //determine servo write method
{
Serial.println(pos);
myservo.writeMicroseconds(pos);
}
else
{
Serial.println(pos);
myservo.write(pos);
}
}
readString=""; //empty for next input
}
I'm not entirely sure what you're trying to accomplish. Are you just trying to have the servo controlled mirror and the "laser tripwire" in the same program?
I'm a self taught, fairly new "Arduino programmer" as well and I'm pretty confidant that I could make those two things work together.
Post your code and elaborate on your goal and we'll make it happen.
As for programming tips, keep messing with things. For me Ebay was my best friend. Just search for "arduino sensor" or something similar and buy a few 2-5$ devices each week. Sparkfun and Adafruit are good sources as well (though more expensive). As you get them in the mail (or better, before you buy them), use the internet to learn how to hook them up and get data out of them or make them do something useful. Over time you'll gather a large collection of inputs and outputs and the knowledge of how to use them. Once you think of a project using them, it will lead you to other things to learn and devices to obtain and so on.
Also, if you want to diversify your programming knowledge, you can try out Processing, (Getting Started / Processing.org) which uses JavaScript and is equally easy to learn or even learn how to build Android apps (Developer Guides | Android Developers).
If you are looking to build a galvo, here is one way to do it...
I Just re-read your post and saw that you probably don't have any code at all yet.
For the servos, just look at the examples for servos that come with the Arduino software. If there's anything in there that you don't understand, look it up on the Arduino reference page (Arduino - Home) and play around with it until you understand it.
For the "laser tripwire" if you have it working with only basic electronics there must be something that is telling you that it's working like an LED or a buzzer. If so, you just need to connect whatever that output is to an input of your Arduino and monitor that in some way. I would need more details to help further.
Also, even more important than trying new devices is to try out all the examples that come with the Arduino software and use the reference/forum searches for things you don't understand.
DavidOConnor:
If you are looking to build a galvo, here is one way to do it...http://www.instructables.com/id/Arduino-Laser-Show-with-Full-XY-Control/
Holy crap, that's awesome!
DavidOConnor:
If you are looking to build a galvo, here is one way to do it...http://www.instructables.com/id/Arduino-Laser-Show-with-Full-XY-Control/
looks like my bench... only thing is that usually everything stops when the smoke comes out. : )