Good Morning,
then code for the Master should like this:
#include <VirtualWire.h>
#include <Button.h>
Button sw(2, PULLUP);
#define buttonPin 2 // the number of the pushbutton pin
char buttonState = LOW + '0'; // variable for reading the pushbutton status
const int ledPin = 13; // the number of the LED pin
const int led_pin = 11;
const int transmit_pin = 12;
const int receive_pin = 11;
const int transmit_en_pin = 3; // What is the function ? is end code ?
void setup()
{
vw_set_tx_pin(transmit_pin);
vw_set_rx_pin(receive_pin);
vw_set_ptt_pin(transmit_en_pin);
vw_set_ptt_inverted(true); // what is the function for that ?
vw_setup(2000); // Bits per sec
pinMode(buttonPin, INPUT); //Initialize the button in input
}
void loop()
{
if(sw.uniquePress())
{
buttonState = !buttonState + '0'; // here I need to revert the value if is 0 when press the button should became 1 and viceversa
digitalWrite(ledPin,buttonState);
vw_send((uint8_t *)buttonState, 1); // send out the button state ? correct ?
vw_wait_tx(); // Wait until the whole message is gone
delay(1000);
}
}
I don't know if is right ...
what i'd like to do is :
- press the button then send on --> 1
- press the button again send off --> 0
- for do that I do a "not" of my variabile but the problem if that is char and not integer ... then not of 0 is 1 but not of 1 is not 0 ...
also i don't understand that
vw_send((uint8_t *)buttonState, 1);
so vW_Send is the function for send
uint8_t * --> what does it mean ?
1 --> What does it mean ?
could explain kidly to me shortly ?
Thanks
Andrea