Author Topic: Help with Arduino..!  (Read 9483 times)

0 Members and 1 Guest are viewing this topic.

Offline Mr1234kakiTopic starter

  • Contributor
  • Posts: 11
Help with Arduino..!
« on: September 05, 2012, 07:11:55 am »
My attempt to build a push button counter with interrupt,It didnt work though, im not good at programming please help me out, =)

What im trying to do is , i dsplay the initial value at 25 on the lcd display
then when i push the interrupt button, i will move to the counter function
the counter will then calculate how many time i have push the button and add the value to the intial 25, x = pushcounter +25
then i will stop the counter function and return to the main loop function and displaying the new value after being added with pushcounter values

we will have three button for return, interupt, and counter

Cheers! Thanks in advance ;D
 

Offline shebu18

  • Frequent Contributor
  • **
  • Posts: 309
  • Country: ro
Re: Help with Arduino..!
« Reply #1 on: September 05, 2012, 07:44:17 am »
What you are trying to do has a example in the IDE. Search there, using the interrupt is a bit complicated.
 

Offline poorchava

  • Super Contributor
  • ***
  • Posts: 1673
  • Country: pl
  • Troll Cave Electronics!
Re: Help with Arduino..!
« Reply #2 on: September 05, 2012, 08:12:24 am »
This will sound as an attempt to troll a person (well, it kinda is :D):

Get a real microcontroller. You will not learn programming microcontrollers by using Arduino. When you'll go for a job interview, the recruiter will ask you what programming environments you know and your response will be 'Arduino' the recruiter will most likely perform an action commonly abbreviated as "ROTFL".

You learn Arduino - you know Arduino
You learn C - you can program ANY microcontroller when you get the datasheet (or other corresponding document like 'programming reference')
I love the smell of FR4 in the morning!
 

Offline shebu18

  • Frequent Contributor
  • **
  • Posts: 309
  • Country: ro
Re: Help with Arduino..!
« Reply #3 on: September 05, 2012, 08:45:41 am »
If you do not have programming courses in school then arduino is a good starting point and a easy way to make contact with the world of uC. After some time you will get curious about the other chips and you will want to learn the rel C.
 

Offline Mr1234kakiTopic starter

  • Contributor
  • Posts: 11
Re: Help with Arduino..!
« Reply #4 on: September 05, 2012, 09:02:27 am »
lol, i learnt C languane and C++, but im not that advance to debug the coding, i did what i know and stuck..

im not very good at logic things i guess..
 

Offline HackedFridgeMagnet

  • Super Contributor
  • ***
  • Posts: 2034
  • Country: au
Re: Help with Arduino..!
« Reply #5 on: September 05, 2012, 09:55:45 am »
this guy explains how to do it

http://www.dave-auld.net/index.php?option=com_content&view=article&id=107:arduino-interrupts&catid=53:arduino-input-output-basics&Itemid=107

though you seem to have grabbed similar code anyway.

Start with his code and gradually adapt it to suit your purposes, on step at a time.
Check you have working code at each change.

You cant go wrong...
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 18031
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Help with Arduino..!
« Reply #6 on: September 05, 2012, 11:43:31 am »
I believe the arduino will take straight C if you sent it to it. The problem I have with arduino is that it is so similar to C they might as well have made it a C environment instead of reinvent the wheel. If I tried to learn both I'd end up getting confused. I'll learn C, once I know that I'll be in full control. The statements made by the arduino designers is a load of bollocks, if they really wanted a simple environment that even artists can use they would have used basic not C as C is not at all intuitive but basic is very easy to pick up fo simple artistic needs.
 

Offline madires

  • Super Contributor
  • ***
  • Posts: 8141
  • Country: de
  • A qualified hobbyist ;)
Re: Help with Arduino..!
« Reply #7 on: September 05, 2012, 02:00:59 pm »
I believe the arduino will take straight C if you sent it to it. The problem I have with arduino is that it is so similar to C they might as well have made it a C environment instead of reinvent the wheel. If I tried to learn both I'd end up getting confused. I'll learn C, once I know that I'll be in full control. The statements made by the arduino designers is a load of bollocks, if they really wanted a simple environment that even artists can use they would have used basic not C as C is not at all intuitive but basic is very easy to pick up fo simple artistic needs.

Actually it's (nearly) C++ and the wheel wasn't reinvented. The IDE is just a nice GUI for avr-gcc and avrdude including a simple editor. It also includes a lot of libs and convenience stuff to hide some of the hardware in an abstraction layer for the starters. If you wish you can do anything the hardcore way :-) At most schools and universities students start with Pascal or Java as first programming language. C++ isn't far off but still nearer to the hardware. Arduino hides most of C++ in the libs. So the user isn't bothered too much with it, until he starts writing libs. Starting programming with Basic isn't a good idea for most students, since they have to learn C anyway later on. And if they started with Basic they have to dismiss any programming habits to cope with Pascal/Java/C.
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 18031
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Help with Arduino..!
« Reply #8 on: September 05, 2012, 03:45:10 pm »
My Basic comment was for artists wanting to flash a light, basic is far more suitable for them.

Everything seems to run on C, The book I read about arduino programing that cwas a rubbish book anyway was essentially teaching some basic c with some of the features hidden.
 

Offline madires

  • Super Contributor
  • ***
  • Posts: 8141
  • Country: de
  • A qualified hobbyist ;)
Re: Help with Arduino..!
« Reply #9 on: September 05, 2012, 09:25:05 pm »
My Basic comment was for artists wanting to flash a light, basic is far more suitable for them.

Quick and dirty :-)

Quote
Everything seems to run on C, The book I read about arduino programing that cwas a rubbish book anyway was essentially teaching some basic c with some of the features hidden.

Yep, C rulez :-) But if someone wants to develop software for MCUs professionally he should study two different MCU architectures incl. programming in assembler at least. Otherwise he doesn't know what could be gained by choosing the appropriate MCU and using different programming techniques. A lot of EEs treat MCUs like black boxes. If one isn't fast enough they throw a more powerful one at the problem. With time and cost contraints it's obviously the "save" way to go, but a faster MCU doesn't help with bad code always.
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11713
  • Country: my
  • reassessing directives...
Re: Help with Arduino..!
« Reply #10 on: September 06, 2012, 02:15:57 am »
if you think you can create a better world with Basic then go for it and prove it, dont mourn about another. there are reasons why C is a buzz and used by many. if Basic is an artist drawing with pencil, C is an artist drawing with colors. thats my 2cnts analogy. and if someone say Arduino IDE is not C then its just plain stupid they should go back and learn more, just as if someone say i'm not writing in english right now (broken or your majesty english is another story). Arduino is C just a poor implementation due to struggle to encapsulate and making it easier... by another artists.
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4306
  • Country: us
Re: Help with Arduino..!
« Reply #11 on: September 06, 2012, 04:52:35 am »
(You'll get more help, less complaining, and less digression; if you ask your question on the Arduino Forums at http://arduino.cc )

I suspect that the LCD functions are not callable from within interrupts.  The usual technique would be to have the ISR function read the buttons and update some global variables, and then have the non-ISR loop go and redisplay those values whenever they've changed.
 

jucole

  • Guest
Re: Help with Arduino..!
« Reply #12 on: September 07, 2012, 11:34:50 pm »
I believe Arduino is both good and bad; good in that they can allow people with limited experience to get-up-and-running very quickly; But they are evil because they abstract too many important fundamentals of the system design process.  They're supposed to be aimed at artists - I'm an artist and I find Arduino quite confusing! why do they call source-code a sketch?  I don't call my oil paintings software! ;-)
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 18031
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Help with Arduino..!
« Reply #13 on: September 08, 2012, 06:19:01 am »
C is a serious programming language and is not intuitive. If you have no programming knowledge and look at a C program it will mean nothing at all. I find that it is too compact personally as it just makes no sense unless you know what it is and commenting will be very very important. Basic on the other hand can be pretty much understood if you can deal with logic statements but are not knowledgeable of programing. That is much more suited to artists etc who are not interested in programming. If your into programig and making the most of it you'll probably want to do it in C but the mission statement of the arduino completely conflicts with what it is !
 

Offline Rerouter

  • Super Contributor
  • ***
  • Posts: 4700
  • Country: au
  • Question Everything... Except This Statement
Re: Help with Arduino..!
« Reply #14 on: September 08, 2012, 08:14:13 am »
to me writing arduino code isnt all that different to tying up most of your functions in a library, and as a somewhat begginner at micro code (only had limited understanding of visual basic) i must say it atleast allowed me to start in the right riection, as now i am more and more making direct calls to the hardware while still skipping things it has helped me to better understand it all :/
 

Offline mtkaalund

  • Contributor
  • Posts: 32
  • Country: dk
Re: Help with Arduino..!
« Reply #15 on: September 08, 2012, 08:31:23 am »
The arduino project is a fine attempt to get the masses to do some electronics, but for the arduino framework, in my personally opinion not suitable for development a finished product, but more as a quick 'n' dirty prototyping.
When you are finished with the quick 'n' dirty part, you can just reprogram it using C for avr, flash the chip by using avr-dude, then you got a relativity cheap development board, that is as good as the STK-500.

As it is, I would not use interrupts in the arduino framework, I would go an use avr-gcc when testing interrupts.
"Keep buggering on" -- Winston Churchill
VIR => V = I*R, neat ;)
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 18031
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Help with Arduino..!
« Reply #16 on: September 09, 2012, 08:50:29 pm »
The arduino project is a fine attempt to get the masses to do some electronics,

but it's more about programming and easy lazy programming. like you say it's for the masses, that statement in itself assumes over ease and poor real usability that they will need to see a way out of and into real electronics. Why should I develop my product twice ?
 

Offline Mr1234kakiTopic starter

  • Contributor
  • Posts: 11
Re: Help with Arduino..!
« Reply #17 on: September 10, 2012, 04:55:10 am »
(You'll get more help, less complaining, and less digression; if you ask your question on the Arduino Forums at http://arduino.cc )

I suspect that the LCD functions are not callable from within interrupts.  The usual technique would be to have the ISR function read the buttons and update some global variables, and then have the non-ISR loop go and redisplay those values whenever they've changed.


Thank you! i  got it now!  ;D
 

Offline psycho0815

  • Regular Contributor
  • *
  • Posts: 150
  • Country: de
    • H-REG Blog
Re: Help with Arduino..!
« Reply #18 on: September 10, 2012, 12:02:38 pm »
I really don't see why anyone would have a problem with the arduino ide/language.
if you don't want to use the shortcuts they provide, you can just feed it straight C.
the code is eventually compiled by avr-gcc anyway, so you can just use the basic avr c-lib.
You can even skip the whole arduino stuff, alltogether and program the chip via your normal avr-gcc/avrdude toolchain by using the isp-header.
You should even be able to upload a .hex file via usb using the arduino bootloader.
And if you don't like C at all, i don't see why one couldn't use bascom-avr as a language.

So basically the arduino is just a really cheap prototyping board, or at least that's how i view it.
However i agree that the way it's marketed for non-electronics-people, it would have made more sense to use something like basic as a language.
If you like, check out my blog (german):
http://h-reg.blogspot.de
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 18031
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Help with Arduino..!
« Reply #19 on: September 10, 2012, 12:04:21 pm »
I really don't see why anyone would have a problem with the arduino ide/language.
if you don't want to use the shortcuts they provide, you can just feed it straight C.
the code is eventually compiled by avr-gcc anyway, so you can just use the basic avr c-lib.
You can even skip the whole arduino stuff, alltogether and program the chip via your normal avr-gcc/avrdude toolchain by using the isp-header.
You should even be able to upload a .hex file via usb using the arduino bootloader.
And if you don't like C at all, i don't see why one couldn't use bascom-avr as a language.

So basically the arduino is just a really cheap prototyping board, or at least that's how i view it.
However i agree that the way it's marketed for non-electronics-people, it would have made more sense to use something like basic as a language.


You basically just agreed with me  ;)
 

Offline JuiceKing

  • Regular Contributor
  • *
  • Posts: 233
  • Country: us
Re: Help with Arduino..!
« Reply #20 on: September 10, 2012, 02:49:51 pm »
I got the interrupts to work in a project where I needed to read a keypad. The first key-press would invoke the interrupt handler, which would scan the keyboard for the expected sequence of key presses.

Details with code are here:

https://www.eevblog.com/forum/projects-designs-and-technical-stuff/arduino-metronome-with-keypad-input/msg133329/#msg133329

I don't know how you implemented your button, but make sure that it's not left floating when left open... I pulled mine up and then had the keypad buttons ground the input line, so I tested for a falling edge to invoke the interrupt.

- Ken
 

Offline psycho0815

  • Regular Contributor
  • *
  • Posts: 150
  • Country: de
    • H-REG Blog
Re: Help with Arduino..!
« Reply #21 on: September 10, 2012, 04:24:50 pm »
You basically just agreed with me  ;)

Well English is not my first language, but i think that's what "i agree" usually means isn't it?  ;)
If you like, check out my blog (german):
http://h-reg.blogspot.de
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11713
  • Country: my
  • reassessing directives...
Re: Help with Arduino..!
« Reply #22 on: September 10, 2012, 04:54:29 pm »
You basically just agreed with me  ;)
Well English is not my first language, but i think that's what "i agree" usually means isn't it?  ;)
it means the guy agreed for a moment just before, but now not anymore.
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 18031
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Re: Help with Arduino..!
« Reply #23 on: September 10, 2012, 05:13:36 pm »
You basically just agreed with me  ;)
Well English is not my first language, but i think that's what "i agree" usually means isn't it?  ;)
it means the guy agreed for a moment just before, but now not anymore.

Oh your giving English lessons now ? God help us.

Saying that someone agrees with me is not the same as saying I agree with them. The one agreeing acknowledges that the other holds their view also, having already laid it out on the table.
 

Offline JuiceKing

  • Regular Contributor
  • *
  • Posts: 233
  • Country: us
Re: Help with Arduino..!
« Reply #24 on: September 10, 2012, 05:59:16 pm »
I believe the arduino will take straight C if you sent it to it. The problem I have with arduino is that it is so similar to C they might as well have made it a C environment instead of reinvent the wheel. If I tried to learn both I'd end up getting confused. I'll learn C, once I know that I'll be in full control. The statements made by the arduino designers is a load of bollocks, if they really wanted a simple environment that even artists can use they would have used basic not C as C is not at all intuitive but basic is very easy to pick up fo simple artistic needs.

Actually it's (nearly) C++ and the wheel wasn't reinvented. The IDE is just a nice GUI for avr-gcc and avrdude including a simple editor. It also includes a lot of libs and convenience stuff to hide some of the hardware in an abstraction layer for the starters. If you wish you can do anything the hardcore way :-) At most schools and universities students start with Pascal or Java as first programming language. C++ isn't far off but still nearer to the hardware. Arduino hides most of C++ in the libs. So the user isn't bothered too much with it, until he starts writing libs. Starting programming with Basic isn't a good idea for most students, since they have to learn C anyway later on. And if they started with Basic they have to dismiss any programming habits to cope with Pascal/Java/C.

I'm really glad they did it this way. BASIC is a very poor language in general, and would be especially bad for an embedded controller: no pointer arithmetic, no concept of a stack/scoped variables, no or very weak bitwise operators...

I'm surprised, though, that there is no mention of struct or malloc in the Arduino Language Reference, which are very important features of C. Are they allowed by the compiler?

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf