we can control speed of motor using PWM.
But how does same thing can be done wireless by using a simple rf module.
please let me know in detail.
But how does same thing can be done wireless by using a simple rf module.
please let me know in detail.
You need to provide more details about what you are trying to accomplish. Will there be an Arduino on both ends of the wireless link? If so, you can simply send the value that should be written to the PWM pin, from one Arduino to the other, and have the other Arduino analogWrite that value to a PWM pin.
Ya i'm using two arduino.
I have successfully sent data wirelessly from one arduino to another.
similarly i can send the PWM value. but at the receiver end how can we inplement that that value for analogue write.
please help me dude, i'm stucked.
I have successfully sent data wirelessly from one arduino to another.
Good.
similarly i can send the PWM value
Then, what's the problem?
at the receiver end how can we inplement that that value for analogue write
If you've received a value, just call analogWrite() with that value. If you've received an array of characters, use atoi() to convert the NULL terminated array of characters to an int, and call analogWrite() with that value.
If you've received an array of characters, use atoi() to convert the NULL terminated array of characters to an int, and call analogWrite() with that value.
ya i receive an array of characters,
ya thats what is problem: how to convert array of character to an integer value.
atoi( ):i have never use this function, can i have a demo? or link, sth that explains me.
and how do we do analoge write these values.
atoi( ):i have never use this function, can i have a demo?
Have you tried google?
ya i receive an array of characters,
ya thats what is problem: how to convert array of character to an integer value. atoi( ):i have never use this function, can i have a demo? or link, sth that explains me. and how do we do analoge write these values.
Below is some code I use with servos where a character string is captured and converted to a number. You may be able to modify it for PWM use.
// zoomkat 10-4-10 serial servo test
// type servo position 0 to 180 in serial monitor
// for writeMicroseconds, use a value like 1500
// for IDE 0019 and later
// Powering a servo from the arduino usually DOES NOT WORK.
String readString;
#include <Servo.h>
Servo myservo; // create servo object to control a servo
void setup() {
Serial.begin(9600);
myservo.writeMicroseconds(2000); //set initial servo position if desired
myservo.attach(7); //the pin for the servo control
Serial.println("servo-test-21"); // so I can keep track of what is loaded
}
void loop() {
while (Serial.available()) {
delay(1);
if (Serial.available() >0) {
char c = Serial.read(); //gets one byte from serial buffer
readString += c; //makes the string readString
}
}
if (readString.length() >0) {
Serial.println(readString); //so you can see the captured string
int n;
char carray[6]; //converting string to number
readString.toCharArray(carray, sizeof(carray));
n = atoi(carray);
myservo.writeMicroseconds(n); // for microseconds
//myservo.write(n); //for degees 0-180
readString="";
}
}
i'll go for my work.
thanks a lot.