Go to Post Pneumonoultramicroscopicsilicovolcanoconiosis. Be careful. - Ether [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 12-12-2011, 22:05
Sh1ine Sh1ine is offline
Registered User
FRC #2791
Team Role: Leadership
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Albany NY
Posts: 96
Sh1ine is on a distinguished road
Arduino help -RGB LED

I am a coach for Shaker Robotics. I am in no way, shape, or form associated with our programming department. However, I have been trying to make a sign for a friend as a Christmas present. I have been running into problems with the programming, I have been poking around the Arduino forum without much luck and it just hit me that I should post on CD...I don't know why I did not think about this before!

I could really use some help from someone who knows something about programming.

The Task: Mr friend is a member of the local Derby team. I want to make her a sign that uses 1 meter of RGB Flexable LEDs to make a fun and flashy sign. I want to use a push button to turn it on, select one of four programs (Fade through the rainbow, Fade between Orange and Pink, Strobe, and dim white) and then turn it off.

The Hardware: I am starting with this for the hardware....Thanks Adafruit

I am using the MOSFETs and it is wired up as show in the diagram. I have a pull-down push button switch connected to Digital IO 2.


What I have done: So I though that this would be relatively straight forward (famous last words!). I used the Change State Detection, and button examples from Arduino. I got the system to work great with a few very simple 1 LED programs (different rates of blink, constant on, etc.) In a completely different sketch I got all of the fades to work. I combined them together and PRESTO...nothing, the program get stuck in a loop at the Rainbow Fade and the Push Button won't work anymore. So I post about it and one guy mentions that I need to use a State Variable code. I have researched it, and I have realized I am not anywhere near the level that I need to be to make this thing work.

This is my thread in the Arduino Forums. The "code" that I have written is posted there.

So the long and short of it, if you are looking for a challenge and would like to help a guy who is much more comfortable teaching Inventor and Machining I would appreciate it! It would make my present a lot cooler.
  #2   Spotlight this post!  
Unread 13-12-2011, 21:10
DonRotolo's Avatar
DonRotolo DonRotolo is offline
Back to humble
FRC #0832
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Atlanta GA
Posts: 6,998
DonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond repute
Re: Arduino help -RGB LED

Well, I'm not much of a programmer either, but what happens, exactly, after you press the button once?

What I see is that you trigger the IF for 1 press. After you go through all those later IF statements for the various fades, then what happens? I think the program doesn't know what to do after the first cycle of fades.

Also, when exactly is the button read in? Can the program get there again during normal runtime? If it can't, then it can't read the button any more and it will appear to be not working.

One thing that works for me is to manually walk through the code with paper to help keep track. It may take an hour, but bugs will be more obvious.
__________________

I am N2IRZ - What's your callsign?
  #3   Spotlight this post!  
Unread 14-12-2011, 09:50
Dave Scheck's Avatar
Dave Scheck Dave Scheck is offline
Registered User
FRC #0111 (WildStang)
Team Role: Engineer
 
Join Date: Feb 2003
Rookie Year: 2002
Location: Arlington Heights, IL
Posts: 574
Dave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond repute
Re: Arduino help -RGB LED

There are a few things in the last code block that you posted in that thread that are concerning.

1. When you initialize your buttonState and lastButtonState varibales at the top, you set them to 0. You should use your LOW/HIGH constants. Depending on how those constants are defined, you could have trouble in your initial comparisons. (probably not causing your problem)

2. I don't see you setting lastbuttonState within your loop. (probably not causing your problem, but will be a problem once your current issue is resolved)

3. You are missing a == in if(pushCounter = 4). That will always evaluates to true and always assign 0 to pushCounter (probably the cause of your problem)
  #4   Spotlight this post!  
Unread 14-12-2011, 11:29
Dave Scheck's Avatar
Dave Scheck Dave Scheck is offline
Registered User
FRC #0111 (WildStang)
Team Role: Engineer
 
Join Date: Feb 2003
Rookie Year: 2002
Location: Arlington Heights, IL
Posts: 574
Dave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond repute
Re: Arduino help -RGB LED

A couple more things that I found that are going to give you problems.

You're declaring ledState variables inside the pushCounter conditions within the loop. It looks like you're intending to try to maintain that state between loops and this will not accomplish that. You're already declaring a global ledState at the top, why are you redeclaring and reinitializing them again in the conditions?

The same goes for previousSlowMillis and previousFastMillis. They will always be 0 since you're reinitializing them every loop.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 23:36.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi