Quantcast
Channel: Arduino Forum - Latest topics
Viewing all articles
Browse latest Browse all 15317

Using the Nano PWM output to controle RC Rotating light

$
0
0

Hi,

I'm trying to control my RC rotating light from my Nano.

The light are supplied with gnd and 5v+ and the PWM signal is connected to D5.
The light is the following:

There are 4 modes on the light, (3 flashing and off).
If I connect the light to my RC reciever, I can switch through the modes using an high/low switch. So setting the PWM signal from low to high, changes the mode.

I'm trying with the followin code:

int pwm1 = 5;
bool _flashOn = false;

void setup()
{
  // put your setup code here, to run once:
  pinMode(pwm1, OUTPUT);
  digitalWrite(pwm1, LOW);
  Serial.begin(9600);
}

void loop()
{
  val = digitalRead(input1);
  if (!_flashOn)
  {
    flashOn();
  }
}

void flashOn()
{
  int pos = 1;
  Serial.println("Flash on");

  for (pos = 0; pos <= flashOnPulse; pos += 1)
  { 
    digitalWrite(pwm1, HIGH);
    delay(500);
    digitalWrite(pwm1, LOW);
    delay(500);
    Serial.println("PWM on");
  }

  _flashOn = true;
}

But nothing happens...
I should go from low to high, two times.

I'm wondering if it could be the hz of the output that's the problem?
As per my goggling the standard RC equipment is running af 50hz PWM..

5 posts - 3 participants

Read full topic


Viewing all articles
Browse latest Browse all 15317

Trending Articles