Help with C code for ATtiny 2313 traffic light
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- russell 27
- Posts: 242
- Joined: Thu Sep 12, 2013 3:59 pm
Help with C code for ATtiny 2313 traffic light
0
Last edited by russell 27 on Tue Aug 26, 2014 11:36 am, edited 2 times in total.
- egutting
- Posts: 297
- Joined: Wed Nov 14, 2012 12:57 am
Re: Help with C code for ATtiny 2313
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....
- adafruit_support_mike
- Posts: 67454
- Joined: Thu Feb 11, 2010 2:51 pm
Re: Help with C code for ATtiny 2313
It sounds like you want the same basic strategy as the one used in the Arduino BlinkWithoutDelay example:
http://arduino.cc/en/Tutorial/BlinkWithoutDelay
http://arduino.cc/en/Tutorial/BlinkWithoutDelay
- russell 27
- Posts: 242
- Joined: Thu Sep 12, 2013 3:59 pm
Re: Help with C code for ATtiny 2313
Thanks for the replies.
- russell 27
- Posts: 242
- Joined: Thu Sep 12, 2013 3:59 pm
Re: Help with C code for ATtiny 2313 traffic light
If anyone could print out the basic define statement how to implement in the code it would be of help.
Thanks.
Thanks.
- adafruit_support_mike
- Posts: 67454
- Joined: Thu Feb 11, 2010 2:51 pm
Re: Help with C code for ATtiny 2313 traffic light
If you mean a precompiler symbol definition, it looks like this:
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.
Code: Select all
#define MY_SYMBOL value
- russell 27
- Posts: 242
- Joined: Thu Sep 12, 2013 3:59 pm
Re: Help with C code for ATtiny 2313 traffic light
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.
- adafruit_support_mike
- Posts: 67454
- Joined: Thu Feb 11, 2010 2:51 pm
Re: Help with C code for ATtiny 2313 traffic light
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.
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.
- egutting
- Posts: 297
- Joined: Wed Nov 14, 2012 12:57 am
Re: Help with C code for ATtiny 2313 traffic light
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
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
- russell 27
- Posts: 242
- Joined: Thu Sep 12, 2013 3:59 pm
Re: Help with C code for ATtiny 2313 traffic light
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.
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.
- russell 27
- Posts: 242
- Joined: Thu Sep 12, 2013 3:59 pm
Re: Help with C code for ATtiny 2313 traffic light
egutting
Thanks for your reply.
Thanks for your reply.
- zener
- Posts: 4567
- Joined: Sat Feb 21, 2009 2:38 am
Re: Help with C code for ATtiny 2313 traffic light
Hey Russell,
Could you put your first post back? Without it this thread makes no sense.
Thanks
Could you put your first post back? Without it this thread makes no sense.
Thanks
Please be positive and constructive with your questions and comments.