Show Posts
|
|
Pages: 1 [2] 3 4 ... 435
|
|
17
|
Using Arduino / Networking, Protocols, and Devices / Re: ENTER key In Serial
|
on: May 17, 2013, 02:34:22 pm
|
i need to program the arduino to send it on a software serial line when it recieves another serial message from the computer In the below simple code the ln part of "Serial.println" adds a carriage return and line feed to what is being sent. // zoomkat 7-30-11 serial I/O string test // type a string in serial monitor. then send or enter // for IDE 0019 and later
String readString;
void setup() { Serial.begin(9600); Serial.println("serial test 0021"); // so I can keep track of what is loaded }
void loop() {
while (Serial.available()) { delay(2); //delay to allow byte to arrive in input buffer char c = Serial.read(); readString += c; }
if (readString.length() >0) { Serial.println(readString);
readString=""; } }
|
|
|
|
|
18
|
Using Arduino / Programming Questions / Re: toggle led
|
on: May 17, 2013, 11:14:29 am
|
i need a sample program for led to toggle, if i press a push button led must on and if i again press the same push button led must get off and wise versa. pls tel me the logic You can try something like below: //zoomkat LED button toggle test 11-08-2012
int button = 5; //button pin, connect to ground as button int press = 0; boolean toggle = true;
void setup() { pinMode(13, OUTPUT); //LED on pin 13 pinMode(button, INPUT); //arduino monitor pin state digitalWrite(5, HIGH); //enable pullups to make pin 5 high }
void loop() { press = digitalRead(button); if (press == LOW) { if(toggle) { digitalWrite(13, HIGH); // set the LED on toggle = !toggle; } else { digitalWrite(13, LOW); // set the LED off toggle = !toggle; } } delay(500); //delay for debounce }
|
|
|
|
|
19
|
Using Arduino / Programming Questions / Re: serial connections
|
on: May 17, 2013, 10:36:46 am
|
just as a simple test, you could try the below code on both the uno and mega. Disconnect the wire between the uno rx pin and mega tx pin to prevent interference during the test, then send something using the uno serial monitor and see if it is echoed back to the uno serial monitor and appears on the mega serial monitor. // zoomkat 7-30-11 serial I/O string test // type a string in serial monitor. then send or enter // for IDE 0019 and later
String readString;
void setup() { Serial.begin(9600); Serial.println("serial test 0021"); // so I can keep track of what is loaded }
void loop() {
while (Serial.available()) { delay(2); //delay to allow byte to arrive in input buffer char c = Serial.read(); readString += c; }
if (readString.length() >0) { Serial.println(readString);
readString=""; } }
|
|
|
|
|
20
|
Using Arduino / Motors, Mechanics, and Power / Re: Example of Servo Pan-Tilt control from Joystick
|
on: May 17, 2013, 12:01:56 am
|
I made the below for future tinkering with joystick/pot servo control via an Ethernet/internet connection. It has a delay and dead band to make serial monitor viewing of what is going on easier, and to prevent an unneeded control position spew which might overload the receiving end. I haven't had a servo hooked up in quite a while, so I need to get back on that. //zoomkat dual pot/servo test 12-29-12 //view output using the serial monitor
#include <Servo.h> Servo myservo1; Servo myservo2;
int potpin1 = 0; //analog input pin A0 int potpin2 = 1;
int newval1, oldval1; int newval2, oldval2;
void setup() { Serial.begin(9600); myservo1.attach(2); myservo2.attach(3); Serial.println("testing dual pot servo"); }
void loop() { newval1 = analogRead(potpin1); newval1 = map(newval1, 0, 1023, 0, 179); if (newval1 < (oldval1-2) || newval1 > (oldval1+2)){ myservo1.write(newval1); Serial.print("1- "); Serial.println(newval1); oldval1=newval1; }
newval2 = analogRead(potpin2); newval2 = map(newval2, 0, 1023, 0, 179); if (newval2 < (oldval2-2) || newval2 > (oldval2+2)){ myservo2.write(newval2); Serial.print("2- "); Serial.println(newval2); oldval2=newval2; } delay(50); }
|
|
|
|
|
24
|
Using Arduino / Motors, Mechanics, and Power / Re: Arduino restarts when DC motors are turned on
|
on: May 16, 2013, 09:48:46 pm
|
If adding a cap doesn't work, I'll focus on further reducing EMI. Using two sources though is out of the question.
I doubt that the above will fix your problem. You might consider getting two UBECs on ebay for powering the arduino and motors from the same power source. I use the below setup to prevent the servos from causing a low voltage drop out of the servo chip when the servo motors start. 
|
|
|
|
|
26
|
Using Arduino / Networking, Protocols, and Devices / Re: How to convert a string from char to ASCII
|
on: May 16, 2013, 08:33:06 pm
|
*********** BELOW WORKS FINE*************************************** String ThisMessage = ("This is some manually entered test data to display"); // This displays properly on the BetaBrite *********** ABOVE WORKS FINE*************************************** If the above works, then you might try the below simple code with the serial monitor (assuming the arduino tx is connected to the betabrite rx, grounds are connected, baud rates set, etc.) and see if what is sent from the serial monitor is echoed back to the serial monitor and the betabrite. If that works, then progress is being made. // zoomkat 7-30-11 serial I/O string test // type a string in serial monitor. then send or enter // for IDE 0019 and later
String readString;
void setup() { Serial.begin(9600); Serial.println("serial test 0021"); // so I can keep track of what is loaded }
void loop() {
while (Serial.available()) { delay(2); //delay to allow byte to arrive in input buffer char c = Serial.read(); readString += c; }
if (readString.length() >0) { Serial.println(readString);
readString=""; } }
|
|
|
|
|