author
8Comments

Tell us about yourself!

Complete Your Profile
  • Arduino ServoTimer2 and VirtualWire 433MHz Receiver

    hi therethank you very much for this post and the continuous help, i finally got the circuit working as expected.

    View Instructable »
  • Arduino ServoTimer2 and VirtualWire 433MHz Receiver

    Ok. One more thing though. Apparently it's only sending the first 2 bytes from the first potententiometer. Only one servo is rotating. What do you think could be the problem? Is it on my tx side or my rx side?

    View Instructable »
  • Arduino ServoTimer2 and VirtualWire 433MHz Receiver

    error message:C:\Users\elijah\Desktop\_2\_2.ino: In function 'void tryGetMessage(int)':_2:58: error: too few arguments to function 'void decode(byte*, int&, int)' decode(message, decodedVal); ^C:\Users\elijah\Desktop\_2\_2.ino:69:6: note: declared here void decode(byte * encoded, int & decoded, int idx ) { ^Multiple libraries were found for "ServoTimer2.h" Used: C:\Program Files (x86)\Arduino\libraries\ServoTimer2 Not used: C:\Users\elijah\Documents\Arduino\libraries\ServoTimer2-masterexit status 1too few arguments to function 'void decode(byte*, int&, int)'

    after changing those 2 lines in the receiver code, here the error i get: void decode(byte * encoded, int & decoded, int idx ) { ^Multiple libraries were found for "ServoTimer2.h" Used: C:\Program Files (x86)\Arduino\libraries\ServoTimer2 Not used: C:\Users\elijah\Documents\Arduino\libraries\ServoTimer2-masterexit status 1too few arguments to function 'void decode(byte*, int&, int)'

    View Instructable »
  • Arduino ServoTimer2 and VirtualWire 433MHz Receiver

    helloi tried to follow your instructions and modify your codes, but i didnt get the result i wanted as all 3 potentiometers are only controlling one servo. i have attached my tx and rx codes for you to have a look and correct if you find mistakes. please bare in mind i am a beginner at programming.tx code:#include <VirtualWire.h>// Digital pin for LEDconst int led_pin = 13;// Digital pin for transmitterconst int transmit_pin = 3; // Analog pin for Potint potPin1 = 3;int potPin2 = 4;int potPin3 = 5;int potVal1 = 0;int potVal2 = 0;int potVal3 = 0;byte encodedVal[6];void setup(){ // Initialise the transmitter vw_set_tx_pin(transmit_pin); vw_setup(2000); // Bits per sec // The LED isn't necessary but gives a visual // indication that something is happening pinMode(led_pin,...

    see more »

    helloi tried to follow your instructions and modify your codes, but i didnt get the result i wanted as all 3 potentiometers are only controlling one servo. i have attached my tx and rx codes for you to have a look and correct if you find mistakes. please bare in mind i am a beginner at programming.tx code:#include <VirtualWire.h>// Digital pin for LEDconst int led_pin = 13;// Digital pin for transmitterconst int transmit_pin = 3; // Analog pin for Potint potPin1 = 3;int potPin2 = 4;int potPin3 = 5;int potVal1 = 0;int potVal2 = 0;int potVal3 = 0;byte encodedVal[6];void setup(){ // Initialise the transmitter vw_set_tx_pin(transmit_pin); vw_setup(2000); // Bits per sec // The LED isn't necessary but gives a visual // indication that something is happening pinMode(led_pin, OUTPUT);}void loop(){ // Read the pot potVal1 = analogRead(potPin1); potVal2 = analogRead(potPin2); potVal3 = analogRead(potPin3); // Convert int (PotVal) to byte array (encodedVal) encode1(potVal1, encodedVal); digitalWrite(led_pin, HIGH); encode2(potVal2, encodedVal); digitalWrite(led_pin, HIGH); encode3(potVal3, encodedVal); // Flash a light to show transmitting digitalWrite(led_pin, HIGH); // Send the byte array using the transmitter send(encodedVal); digitalWrite(led_pin, LOW); // Wait a little bit before repeating delay(10);}// Convert int to a 2 byte arrayvoid encode1(int val1, byte *encoded ) { encoded[0] = lowByte(val1); encoded[1] = highByte(val1);}void encode2(int val2, byte *encoded ) { encoded[2] = lowByte(val2); encoded[3] = highByte(val2);}void encode3(int val3, byte *encoded ) { encoded[4] = lowByte(val3); encoded[5] = highByte(val3);}// Send byte arrayvoid send (byte *message) { vw_send(message, sizeof(message)); vw_wait_tx(); // Wait until the whole message is gone }rx code:#include <VirtualWire.h>#include <ServoTimer2.h>#define MIN_PULSE 750#define MAX_PULSE 2250const int led_pin = 13;const int receive_pin = 4;const int servo_pin1 = 10;const int servo_pin2 = 11;const int servo_pin3 = 12;// a buffer to store the incoming messages byte message[VW_MAX_MESSAGE_LEN]; // the size of the messagebyte messageLength = VW_MAX_MESSAGE_LEN;// Value decoded from messageint decodedVal1;int decodedVal2;int decodedVal3;// Value mapped from Pot to Servoint mappedVal1; int mappedVal2;int mappedVal3; ServoTimer2 servo1;ServoTimer2 servo2;ServoTimer2 servo3;void setup(){ pinMode(led_pin, OUTPUT); // Initialise the IO and ISR vw_set_rx_pin(receive_pin); vw_setup(2000); // Bits per sec}void loop(){ readMessage();}void readMessage() { vw_rx_start(); tryGetMessage(10); vw_rx_stop(); }void tryGetMessage(int times) { bool gotMessage = false; int i = 0; while(i++ < times && !gotMessage) { if (vw_get_message(message, &messageLength)) { if (message[7] ==0) { gotMessage = true; // Flash a light to show received good message digitalWrite(led_pin, HIGH); decode1(message, decodedVal1); decode2(message, decodedVal2); decode3(message, decodedVal3); mappedVal1 = map(decodedVal1, 0, 1023, MAX_PULSE_WIDTH, MIN_PULSE_WIDTH); mappedVal2 = map(decodedVal2, 0, 1023, MAX_PULSE_WIDTH, MIN_PULSE_WIDTH); mappedVal3 = map(decodedVal3, 0, 1023, MAX_PULSE_WIDTH, MIN_PULSE_WIDTH); digitalWrite(led_pin, LOW); } } } delay(10); servo1.attach(servo_pin1); servo1.write(mappedVal1); delay(20); servo1.detach(); delay(20); servo2.attach(servo_pin2); servo2.write(mappedVal2); delay(20); servo2.detach(); delay(20); servo3.attach(servo_pin3); servo3.write(mappedVal3); delay(20); servo3.detach(); delay(20); }// Convert the two bytes back to intvoid decode1(byte * encoded, int & decoded ) { decoded = (short)(((encoded[1]) & 0xFF) << 8 | (encoded[0]) & 0xFF);}// Convert the two bytes back to intvoid decode2(byte * encoded, int & decoded ) { decoded = (short)(((encoded[3]) & 0xFF) << 8 | (encoded[2]) & 0xFF);}// Convert the two bytes back to intvoid decode3(byte * encoded, int & decoded ) { decoded = (short)(((encoded[5]) & 0xFF) << 8 | (encoded[4]) & 0xFF);}

    View Instructable »
  • Arduino ServoTimer2 and VirtualWire 433MHz Receiver

    Hi thereThank you it finally compiles. But I need your help with my project. I want to control 2 servo motors using 2 potentiometers. Do you think it's possible to modify your codes and get it to work. Please help me if you can, I'm a final year student. thank you

    Hi thereThank you it finally compiles. But I need your help with my project. I want to control 3* servo motors using 3* potentiometers. Do you think it's possible to modify your codes and get it to work. Please help me if you can, I'm a final year student. thank you

    View Instructable »
  • Arduino ServoTimer2 and VirtualWire 433MHz Receiver

    hi therethanks for sharing your project. im dong a similar project and im still getting that error: conflicting declaration 'typedef uint8_t boolean' even after editing ServoTimer2.h as you explained. what should i do now??please help, im a final year student. thank you!

    View Instructable »