I've got two pieces of code that work. One is a light sensor that puts two railway coaches lights on then a station kiosk light when its dark enough. I've got a delay between each of them. This all works fine.
Next I've got a bit of random code to flicker two yellow LED's and one red LED and I've put them in the fire box of a small model kit loco. This also works fine and looks really nice.
My problem is the fire box flicker works ok on its own but when I add it to the lighting program it does what I expected; flickers then goes solid whilst the rest of the code runs then flickers etc. I'm thinking this is because the flicker code runs then stops whilst the light code runs. Is there any way to run the two codes on one arduino and still have a constant flicker? I've tried all sorts (limited knowledge) but can't get what I want. Any ideas?
I've got the two sets of codes called in the void loop () section as per the example and the lights coming on and going off work fine. The flickering lights do come on but they're steady not flickering. It's as if its stopped using the random code. If I comment out the code for the lights on and off the flickering resumes. I feel like I'm almost there!
I'm not a coder and the link to Robin2's example was something I could understand. The links to the examples on thebox have almost fried my head. I think it's time to have a break and go and watch some footie!
I think you are using the Delay() function, if so learn how to use the mills function in a non blocking mode. When you solve that your code will probably work.
Yes, you're right gilshultz, I am using several delays in the code for the lights. Ive actually tried running the program with the delays all commented out but it made no difference. I have noticed that the LED's that are supposed to flicker do actually change from time to time but it is very slowly.
I'll post the code I'm using as soon as I remember how to do it on this forum.
Just time to try things out I'm afraid. I was looking for a quick fix but hopefully next week I'll get a bit of time to myself to go through your tutorial properly. I like to see if I can do things myself first. As a note I did try commenting out all the delays but it made no difference.
Yep, you're right, I've just gone through my code again and realised I'd missed commenting one of the delays out. Now they're all commented out it all works. Lights on the coaches and kiosk come on straight away but I'll go through the tutorial to see if I can get it to work how I want.
Well I got your code to work Paul, I had to change A8 to A0 and the > to < for the threshold, but unfortunately the LED's don't flicker. It's much neater than what I have though.
I'll still look at Grumpy_Mike's tutorial to see if I can get it to work that way.
Hi Paul, not quite sure what you're asking. Do you want me to post the sketch I'm using? It's pretty much yours with the minor alterations. I've already tried it on my arduino.