A simple auto-reformat (ctrl-T) by the IDE makes this code a lot more readable:
#include <RH_ASK.h>
#include <SPI.h>
RH_ASK driver;
boolean check = true;
int buttonState = 0;
const int buttonPin = 2;
int PIR = 7;
void setup() {
// put your setup code here, to run once:
pinMode(13, OUTPUT);
pinMode(buttonPin, INPUT);
digitalWrite(buttonPin, LOW);
pinMode (PIR, INPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(13, check);
buttonState = digitalRead(buttonPin);
int sense = digitalRead(PIR);
if (buttonState == LOW) {
check = false;
}
else if (buttonState == HIGH) {
if (check == true) {
;
}
else if (sense == HIGH) {
check = true;
}
}
Serial.println(sense);
if ( check == true) {
const char *msg = "a";
driver.send((uint8_t *)msg, strlen(msg));
driver.waitPacketSent();
Serial.println("yay");
}
}
That's some oddly nested if/else statement set indeed. Are you sure this is what you want to do?
Reading the screenshot, it seems like your code freezes the moment sense becomes 1 aka HIGH. When this happens, and buttonPin is HIGH (button not pressed?), check is set to true and the last block of your loop() is entered:
if ( check == true) {
const char *msg = "a";
driver.send((uint8_t *)msg, strlen(msg));
driver.waitPacketSent();
Serial.println("yay");
}
So my money is on the problem being related to whatever this "driver" is doing.