back to newbie again need help with switching led

am after making a relay turn a light on and off from a press of a radio remote button. but all i am getting is it flashing really fast when the button is pressed.

i am just getting back in to the arduino scene after a bad accident and my memory has been affected normal i would be able to fly through this but i am finding it hard to recall anything from my memory.
so can someone help me recall what i need to do.

this is my code below. and i know i am starting at the beginning. but this is really frustrating for me its like trying to learn to walk again but not knowing how to move your foot.

i need this to only switch once so it it sees pin 7 change. if the light is on turn it off and if it is off turn it on.

i do remember seeing something like this b4 but cant remember what its called or where to find it…

my starting code is below it works on a tattie switch but not on the radio remote

int sensorPin = A0;    // select the input pin for the potentiometer
int ledPin = 13;      // select the pin for the LED
int sensorValue = 0;  // variable to store the value coming from the sensor

void setup() {
  // declare the ledPin as an OUTPUT:
  pinMode(ledPin, OUTPUT);
}

void loop() {
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);
  // turn the ledPin on
  digitalWrite(ledPin, HIGH);
  // stop the program for <sensorValue> milliseconds:
  delay(sensorValue);
  // turn the ledPin off:
  digitalWrite(ledPin, LOW);
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);
}

Your code is making the potentiometer change the rate of strobing.

I think you're needing to use a state change detection setup.

I don't see what a potentiometer has to do with just turning on and then off an LED.

Can you explain what your goal is, more clearly?

There is no pin 7 in your code.

If you want to turn something on/off you need to lock it into a state until something happens.

The code you show just loops, there is no checking of an input such as in a if() section of code.

There is no pin 7 in the code.

I think you should calm down a bit and rephrase your request for help.

.

mikewitney:
am after making a relay turn a light on and off from a press of a radio remote button. but all i am getting is it flashing really fast when the button is pressed.

Does the radio remote send a series of presses for as long as the button is held down? I would guess that it would, because the transport is not all that reliable.

I assume pin 7 might be connected to a button.

byte prevButtonState=0;
void listenButtonPress(){
  int state = digitalRead(7);
  if(state!=prevButtonState){
    if(state==HIGH)
      //switch on the light
    else
       //switch off the light
  }
  prevButtonState=state;
}

hope it will get you started.