Show Posts
|
|
Pages: 1 [2] 3 4
|
|
17
|
Using Arduino / Motors, Mechanics, and Power / DC Motor and Potentiometer positioning
|
on: March 08, 2013, 09:22:38 am
|
hey gays i want to make my dc motor to run with a Precision potentiometer. 10 gears left and right when the max or min position its achieved and from reading the serial the motor should position it self have written some simple code but don't now how to do it further (didn't make this yet) so heave some understanding and if your could help me further i did it appreciated int Enable_A=13; int Enable_B=8; int Input_1=12; int Input_2=11; int Input_3=10; int Input_4=9; int Poti=A0; int val;
void setup() { Serial.begin(115200); Serial.println("REEDY"); pinMode(Enable_A,OUTPUT); pinMode(Enable_B,OUTPUT); pinMode(Input_1,OUTPUT); pinMode(Input_2,OUTPUT); pinMode(Input_3,OUTPUT); pinMode(Input_4,OUTPUT); }
void loop() { while(Serial.available() > 0) { char aChar = Serial.read(); if (aChar=='1') { Motor_ON(); Serial.print("Motor_ON and running 1_3 "); Motor_1_3(); Motor_OFF(); }
if (aChar=='2') { Motor_ON(); Serial.print("Motor_ON and running 2_4 "); Motor_2_4(); Motor_OFF(); } if (aChar=='3') { Potie(); } } }
void Motor_ON() { digitalWrite(Enable_A,HIGH); digitalWrite(Enable_B,HIGH); }
void Motor_OFF() { delay(100); digitalWrite(Enable_A,LOW); digitalWrite(Enable_B,LOW); Motor_Coast(); Serial.println("STOP"); }
void Motor_1_3() { digitalWrite(Input_1,HIGH); digitalWrite(Input_2,LOW); digitalWrite(Input_3,HIGH); digitalWrite(Input_4,LOW); }
void Motor_2_4() { digitalWrite(Input_1,LOW); digitalWrite(Input_2,HIGH); digitalWrite(Input_3,LOW); digitalWrite(Input_4,HIGH); }
void Motor_Coast() { digitalWrite(Input_1,LOW); digitalWrite(Input_2,LOW); digitalWrite(Input_3,LOW); digitalWrite(Input_4,LOW); Potie(); }
void Potie() { val=analogRead(Poti); Serial.print("Poti = "); Serial.println(val); }
|
|
|
|
|
19
|
Using Arduino / Programming Questions / mega and output voltage
|
on: November 05, 2012, 12:35:15 pm
|
hey guys have some issue with my project her the code void loop() { Usb.Task(); if(PS3.PS3Connected) { if(PS3.getButtonPress(DOWN)) { digitalWrite(led_v1,HIGH); { digitalWrite(led_v1,LOW); } } if (PS3.getAnalogButton(L2_ANALOG) > 0 ) { digitalWrite(led_v6,HIGH); delay(5); { digitalWrite(led_v6,LOW); } } if (PS3.getButtonClick(TRIANGLE)) { digitalWrite(led_v1,HIGH); } } }
if i use this "if(PS3.getButtonPress(DOWN))" my output voltage is 145,5mV and if i use "if (PS3.getButtonClick(TRIANGLE))" my output voltage is 4,980V and this is when i use USB cable and when i switch to a dc adapter (7,5V 0,6A) the voltage is the same i wouldn't bother wit this at all but im use now a 5VDC Relay and a LED 5V and i need fast 4,5V to enable this relay and if i use deley() the voltage is i around 5V
|
|
|
|
|
22
|
Development / Other Software Development / [Visual Studio 2010] Couldn't determine program size
|
on: November 03, 2012, 06:49:10 am
|
hey guys have some problem with VS i cant build my solution im getting this error Compiling 'H-Bridge' for 'Arduino Mega 2560 or Mega ADK' core.a(main.cpp.o)* : : In function `main': main.cpp : undefined reference to `setup' main.cpp : undefined reference to `loop' avr-objcopy* : : 'C:\Users\THX\AppData\Local\VMicro\Arduino\Builds\H-Bridge\mega2560\H-Bridge.elf': No such file avr-objcopy* : : 'C:\Users\THX\AppData\Local\VMicro\Arduino\Builds\H-Bridge\mega2560\H-Bridge.elf': No such file Couldn't determine program size:
on arduino its compiling without any issue can some one help
|
|
|
|
|
24
|
Using Arduino / Motors, Mechanics, and Power / Re: motor runing one lap
|
on: October 29, 2012, 11:49:27 am
|
the home position is open if the motor run the switch is closed have modified the code int motor=2; int sw=3; void setup(){ pinMode(motor, OUTPUT); pinMode(sw, INPUT_PULLUP); Serial.begin(115200); Serial.print("REDY"); } void loop(){ while(Serial.available()>0) { char aChar=Serial.read(); if (aChar=='g') { Serial.println("RUN"); digitalWrite(motor,HIGH); } } if (digitalRead(sw)==HIGH) { Serial.println("STOP"); digitalWrite(motor, LOW); } } but now my serial print STOP all the time and i cant restart the motor
|
|
|
|
|
26
|
Using Arduino / Motors, Mechanics, and Power / motor runing one lap
|
on: October 28, 2012, 12:01:56 pm
|
im trying to make my motor to run only one lap wait and to run another lap but have some issue int motor=2; int button=3; void setup(){ pinMode(motor, OUTPUT); pinMode(button, INPUT); Serial.begin(115200); Serial.print("REDY"); } void loop(){ while(Serial.available()>0) { char aChar=Serial.read(); if (aChar=='g') { Serial.println("RUN"); digitalWrite(motor,HIGH); digitalRead(button)==LOW; } } if (digitalRead(button)==HIGH) { Serial.println("STOP"); digitalWrite(motor, LOW); } } i try different setups wit this code but my motor run one lap or he stops and stays stop or hes not runing
|
|
|
|
|
29
|
Using Arduino / Project Guidance / Re: serial read echo and servo
|
on: October 15, 2012, 11:54:42 am
|
char inData[10]; int index; boolean started = false; boolean ended = false; boolean final = false; int serialValues[16]; int serialIndex = 0; const int Pin13 = 13; const int Pin12 = 12; const int Pin11 = 11; const int Pin10 = 10; int buttonState1 = 0; int buttonState2 = 0;
void setup() { //Serial1.begin(9600); Serial.begin(9600);
//setting pinouts pinMode(Pin13, OUTPUT); pinMode(Pin12, OUTPUT); pinMode(Pin11, INPUT); pinMode(Pin10, INPUT); }
void loop() { buttonState1 = digitalRead(Pin11); buttonState2 = digitalRead(Pin10); while(Serial.available() > 0) { char aChar = Serial.read(); if(aChar == '<') { started = true; index = 0; inData[index] = '\0'; } else if(aChar == '>') { ended = true; } else if(started) { inData[index] = aChar; index++; inData[index] = '\0'; } else if (aChar =='*') { final = true; } }
if(started && ended) { // Convert the string to an integer int inInt = atoi(inData); Serial.println(inInt); // Use the value serialValues [serialIndex] = inInt; serialIndex++; // Get ready for the next time started = false; ended = false;
index = 0; inData[index] = '\0'; } if(final) while(1) { // loop through the serialValues, and do something for(int b=0; b <16;b++ ) { int nextVal = serialValues; //if serial value is 24 and pin10 is connected to 5V switch led12 on if (nextVal == 24 && buttonState2 == HIGH) { digitalWrite(Pin12, HIGH); } //if serial value is 12 and pin11 is connected to 5V switch led13 on if (nextVal == 12 && buttonState2 == LOW) { digitalWrite(Pin12, LOW); } Serial.println(b); delay(1000); } } }
|
|
|
|
|