Help with C code for ATtiny 2313 traffic light

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
russell 27
 
Posts: 242
Joined: Thu Sep 12, 2013 3:59 pm

Help with C code for ATtiny 2313 traffic light

Post by russell 27 »

0
Last edited by russell 27 on Tue Aug 26, 2014 11:36 am, edited 2 times in total.

User avatar
egutting
 
Posts: 297
Joined: Wed Nov 14, 2012 12:57 am

Re: Help with C code for ATtiny 2313

Post by egutting »

Could you use an ISR to check the pin to see if it changes to high. When it does, set a marker. Check the marker after each step of your loop and break if the marker is set. Just throwing out an idea....

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Help with C code for ATtiny 2313

Post by adafruit_support_mike »

It sounds like you want the same basic strategy as the one used in the Arduino BlinkWithoutDelay example:

http://arduino.cc/en/Tutorial/BlinkWithoutDelay

User avatar
russell 27
 
Posts: 242
Joined: Thu Sep 12, 2013 3:59 pm

Re: Help with C code for ATtiny 2313

Post by russell 27 »

Thanks for the replies.

User avatar
russell 27
 
Posts: 242
Joined: Thu Sep 12, 2013 3:59 pm

Re: Help with C code for ATtiny 2313 traffic light

Post by russell 27 »

If anyone could print out the basic define statement how to implement in the code it would be of help.
Thanks.

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Help with C code for ATtiny 2313 traffic light

Post by adafruit_support_mike »

If you mean a precompiler symbol definition, it looks like this:

Code: Select all

#define MY_SYMBOL value
When you build a hexfile, the precompiler will go through your source code replacing every occurrence of 'MY_SYMBOL' with 'value' before passing the code to the actual compiler.

User avatar
russell 27
 
Posts: 242
Joined: Thu Sep 12, 2013 3:59 pm

Re: Help with C code for ATtiny 2313 traffic light

Post by russell 27 »

Guess I didn't ask this question properly. I used # define in my code. I do not know how to define or write the statements to accomplish what I had asked initially. I do not use ARDUINO, looking at those sketches are no help, entirely different defines . Maybe too tall a question.

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Help with C code for ATtiny 2313 traffic light

Post by adafruit_support_mike »

It doesn't matter if you're using an Arduino or not. Read the code and figure out what it's doing.

Any program, regardless of language or platform, breaks some kind of job down into a series of steps a computer can do. The technical term for that is 'algorithm'. You can use the same algorithm on any language or platform, even if you can't copy/paste the code.

Learning to read code and figure out the underlying algorithm is an essential programming skill. If you can't answer the questions, "what job does this code do?" and "how does it do that job?" you need to spend more time reading and thinking.

If you were asking me to write the code that implements the BlinkWithoutDelay algorithm for an ATtiny2313, I'm not going to do that. I've pointed you to an example that isn't too hard to understand. Your job now is to read the code, understand the algorithm, and figure out how to carry those ideas over to the ATtiny2313.

I'll answer specific questions about the algorithm or moving it to the ATtiny2313, but you'll need to show the work you've done to get as far as you have.

User avatar
egutting
 
Posts: 297
Joined: Wed Nov 14, 2012 12:57 am

Re: Help with C code for ATtiny 2313 traffic light

Post by egutting »

I'll give some examples of what I'm saying....
Here is how I do pin change interrupts on trinket (ATtiny85):
http://forums.adafruit.com/viewtopic.php?f=52&t=57848

Here is a Arduino sketch that shows checking if an interrupt has occurred:
https://github.com/THP-JOE/AS3935_Wire/ ... tector.ino

User avatar
russell 27
 
Posts: 242
Joined: Thu Sep 12, 2013 3:59 pm

Re: Help with C code for ATtiny 2313 traffic light

Post by russell 27 »

Mike
If you looked at my code in the first place you would see this is not what I am asking, or want to do. Apparently this prompts your assuming, condescending attitude. Sorry To waste your time and more importantly mine. I, in no way ever asked you to write my code. ADAFRUIT's prospectus is prescribed to be a learning, teaching environment. The only thing that is hard to understand is YOU.

User avatar
russell 27
 
Posts: 242
Joined: Thu Sep 12, 2013 3:59 pm

Re: Help with C code for ATtiny 2313 traffic light

Post by russell 27 »

egutting

Thanks for your reply.

User avatar
zener
 
Posts: 4567
Joined: Sat Feb 21, 2009 2:38 am

Re: Help with C code for ATtiny 2313 traffic light

Post by zener »

Hey Russell,

Could you put your first post back? Without it this thread makes no sense.

Thanks

Locked
Please be positive and constructive with your questions and comments.

Return to “Microcontrollers”