So I am currently controlling LED lighting through a relay using Arduino and have also connected a vibration pillow to simulate vibration through another relay also controlled by Arduino. The difference is the light needs to be controlled by the switch, (I have got the light to work successfully without the vibration, merely stand alone but introducing the vibration pillow code wise has complicated things), but not the pillow. The code that is below is what I have got but the light is not controlled by the switch and then when I alter the code, the pillow is controlled by the switch - whereas, I want the switch to control the light but not the vibration pillow. Any help would be gratefully appreciated - thanks so much!
Suggest you ad more serial.write and serial.print to display variables and display where you are in the program and I bet you can figure out the logic problem. SOP, I think.
You cannot avoid the auto-format feature and expect us to read this stuff.
You cannot throw braces {} around at random and survive.
You should not have both a Serial.begin(9200) and a Serial.begin(9600).
Something called lightsOn should not be turning the pillow on.
lightsOn should not have a call to Serial.begin or to pinMode. Those calls are needed but belong in setup().
Fix those problems, post again, and then I can try to help you.
Thanks for your responses. I am sorry for the mistakes - I am very much a beginner. I am trying to work out where to put the pillow delay function in order for it to not be operated by the switch - any help or advice on how to format would be appreciated
If I understand the code and description correct, you want the pillow to be on for 8 seconds and off for 3 seconds, and this should go on all the time.
You also want the led to be controlled by a switch.
You have some libraries which I am unaware of, but they seems to assist your timing.