Hi to everyone.
Yes, I am a noob in programming, sorry for this.
Before writing about my problem I tried to fix it by myself, I have read how to use interrupts (http://www.gammon.com.au/interrupts) and I2C and led control, but it seems to be more difficult especially topics on interrupts...
I am trying to make the program to control servos, LEDs and ledstrip with Arduino based on incoming signal from my radio reciever, because it seems to me more convenient to perform all the actions automatically. The program should control gear retracts, gear door and nose wheel servo of a radio controlled airplane and also the leds and landing lights. I have already compiled the code for everything but the ledstrip control.
I am using Arduino Uno for everything but the ledstrip control which is controlled with Arduino Micro.
Connection scheme is the following:
- Reciever gear channel is connected to digital pin 9 on Uno. Uno is used to read incoming rc signal and depending on the signal and pinchangeinterrupt to control servos, and also as a master when sending the signal via I2C to Micro. LEDs are controlled independently from rc signal based on millis.
As I had troubles with the usage of interrupts and ledstrip control simultaneously I added Micro to control ledstrip state - "on"/"off". - Pins 4 and 5 on Uno are connected to pins 2 and 3 on Micro. Both Arduinos have independent power supply and common ground. 1 kOhm resistors are connected from VIN to pins 2 and 3 on Micro.
- Ledstrip is connected in accordance with description - The Magic of NeoPixels | Adafruit NeoPixel Überguide | Adafruit Learning System
Pin 6 on Micro is connected to DIN on ledstrip, there is 470 Ohm resistor on the side of Micro pin 6
Ledstrip has independent power supply on 12V, 1000F capacitor is also connected
I have problems with LedStripControl_I2C code and my ledstrip does not work as planned. Though it seems to be switching on and off but not in accordance with the incoming I2C signal - it turns on correctly when the signal comes in, but it does not turn off...
Sketches are attached.
Due to I am a noob in programming I understand that I have problems with the code on the side of Micro to control ledstrip. My thoughts are:
- Maybe I have an error in receiveEvent code
- Maybe I need to add interrupts to pin 2 and 3 (I2C pins)
Please help.
GearControl.ino (9.34 KB)
LedStripControl_I2C.ino (2.11 KB)