I copied a script from a YouTube video because there was no download link to the script, but now i'm always getting the same error message and I don't know what to do. Could you help me?
This is my code:
#include <VirtualWire.h>
int ledPassive = 5;
int ledActive = 7;
int motor = 8;
void setup() {
// put your setup code here, to run once:
pinMode(ledPassive,OUTPUT);
pinMode(ledActive,OUTPUT);
pinMode(motor,OUTPUT);
vw_set_ptt_inverted(true);
vw_set_rx_pin(12);
vw_setup(4000);
vw_rx_start();
}
void loop()
{
digitalWrite(ledPassive,HIGH);
digitalWrite(motor,LOW);
digitalWrite(ledActive,LOW);
uint8_t buf(VW_MAX_MESSAGE_LEN);
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)) {
if (buf[0]=='X'){
digitalWrite(ledPassive,LOW);
for (int i=0;i<10;i++){
digitalWrite(motor,LOW);
digitalWrite(ledActive,HIGH);
delay(200);
digitalWrite(motor,HIGH);
digitalWrite(ledActive,LOW);
delay(200);
}
}
else if (buf[0]!='x'){
digitalWrite(ledPassive,HIGH);
}
}
}
And this is the error message:
Arduino: 1.6.10 (Windows 10), Board:"Arduino Nano, ATmega328"
In function 'void loop()':
sketch_aug18e_self_made:29: error: invalid types 'uint8_t {aka unsigned char}[int]' for array subscript
if (buf[0]=='X'){
^
sketch_aug18e_self_made:40: error: invalid types 'uint8_t {aka unsigned char}[int]' for array subscript
else if (buf[0]!='x'){
^
exit status 1
invalid types 'uint8_t {aka unsigned char}[int]' for array subscript
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Sorry for the bad language i'm dutch and not so very good at English