Society of Robots - Robot Forum
Software => Software => Topic started by: harpo on May 21, 2011, 01:31:20 PM
-
hello and welcome to my post
as i have said in the subject i am new to arduino
so far i have made a led blink.
what i would like to do is use a photo cell as a sensor
and have the resistance listed on my laptops screen example "photocell = 76"
ty for reading and have a anice day
-
What you likely want to do is create a voltage divider with the photocell and a fixed resistor. The Arduino then measures the voltage across one and you get your number.
Set this up on a breadboard first and use your voltmeter to see the change. Pick a fixed resistor such that you don't feed too high a voltage to the Arduino. Also, you should measure the resistance through the photocell under both extremes (light and dark) and calculate the voltage divider output to come up with an appropriate fixed resistor. Try it with the photocell on "top" and with the fixed resistor on "top" to see the difference.
-
ah thank you for your replie
i have another thing to ask though
does any1 have a code that would let me controll a server with the "w" and "s" key?
example key hold w server goes 1 way key hold servo goes the other way.
-
Your question is a little confusing. First, there is going to be no code that already does what you're asking. Second, if you want to control the servo from the computer are you using the serial port?...Parallel port?...USB port? You'll need interface hardware in any case.
Or is the servo connected to your Arduino, which is connected to your computer? If so, you'll need to get each part working first. Find code for controlling the servo from the Arduino. Then find examples of sending keystrokes to the Arduino from the PC. Then put them together.
-
i will try to make tis very clear (sry if it was not befor)
i would like to connect a servo ( 9 pwm) to my arduino duemilanove and have the arduino connected to my lap top on com port 4
what i want to do is when i press the "w" button on my keybored my pc will tell the arduino to tell the servo to spin 1 way and when i press "s" i want to the servo to spin the other way.
can someone please provide a detailed explination on how to do this?
thanks
-Harpo
-
#include <Servo.h>
Servo s;
void setup() {
Serial.begin(115200);
s.attach(9);
}
void loop() {
while (Serial.available()) {
switch(Serial.read()) {
case 'w':
case 'W':
s.write(0);
break;
case 's':
case 'S':
s.write(180);
break;
}
}
}
Open up a serial terminal (HyperTerminal or putty or etc) and connect to your Arduino. The above code will listen for commands on the serial port and move accordingly.
-
i thank you for your reply rbtying
but ... somthing screwed up when i lauch my arduino ide the logopops up and it says its loading but after about 1 min it says launch4j a error happend during the launch
it is ide version 0022 with windows vista 32bit
-
Step 1) Assume you messed up, and redownload the IDE
Step 2) Start the IDE. If it doesn't work:
Step 3) Get debug data, and post it here. (screenshots, failure messages, etc)
Step 4) Go ask on the Arduino forums, they know how the IDE works better than SoR
I think the majority of the people here who use AVRs either don't use the Arduino system at all, or eschew the IDE, since it isn't nearly as good as a number of others (it is, however, much simpler.).