Author Topic: Arduino Calculator  (Read 20767 times)

0 Members and 1 Guest are viewing this topic.

Offline skillz21Topic starter

  • Frequent Contributor
  • **
  • Posts: 311
  • Country: au
Arduino Calculator
« on: August 31, 2016, 01:53:59 am »
I want to build a arduino calculator(http://www.instructables.com/id/Arduino-Calculator/) oh btw, i'm not going to make the case, i will just use the circuit. so, heres the scematic(http://www.instructables.com/files/orig/FCD/XDN2/HXII577Q/FCDXDN2HXII577Q.ino) i want this to make a beep every time that any button is pressed.
 

Offline sleemanj

  • Super Contributor
  • ***
  • Posts: 3024
  • Country: nz
  • Professional tightwad.
    • The electronics hobby components I sell.
Re: Arduino Calculator
« Reply #1 on: August 31, 2016, 02:56:05 am »
I want to build a arduino calculator(http://www.instructables.com/id/Arduino-Calculator/) oh btw, i'm not going to make the case, i will just use the circuit. so, heres the scematic(http://www.instructables.com/files/orig/FCD/XDN2/HXII577Q/FCDXDN2HXII577Q.ino) i want this to make a beep every time that any button is pressed.

Show and tell is all well and good, but did you have a question?
~~~
EEVBlog Members - get yourself 10% discount off all my electronic components for sale just use the Buy Direct links and use Coupon Code "eevblog" during checkout.  Shipping from New Zealand, international orders welcome :-)
 

Offline skillz21Topic starter

  • Frequent Contributor
  • **
  • Posts: 311
  • Country: au
Re: Arduino Calculator
« Reply #2 on: August 31, 2016, 04:21:38 am »
I want to build a arduino calculator(http://www.instructables.com/id/Arduino-Calculator/) oh btw, i'm not going to make the case, i will just use the circuit. so, heres the scematic(http://www.instructables.com/files/orig/FCD/XDN2/HXII577Q/FCDXDN2HXII577Q.ino) i want this to make a beep every time that any button is pressed.

Show and tell is all well and good, but did you have a question?
i want this to make a beep every time i press any button
 

Offline sleemanj

  • Super Contributor
  • ***
  • Posts: 3024
  • Country: nz
  • Professional tightwad.
    • The electronics hobby components I sell.
Re: Arduino Calculator
« Reply #3 on: August 31, 2016, 04:35:32 am »
Ok, so what have you tried.

You need

   1. To decide how you will make the sound, will you use a passive piezo, an active buzzer, a speaker, an MP3 player, a servo dinging a bell...
   2. How you will drive that thing that makes the sound, do you need a waveform, can you just set a pin high/low
   3. Locate the place in the code that the keypad is being read and insert code to accomplish 2.

it's not a complex problem, if people were to just tell you "put code X on line 98 and connect device Y to pin N" you would not learn anything.
 
~~~
EEVBlog Members - get yourself 10% discount off all my electronic components for sale just use the Buy Direct links and use Coupon Code "eevblog" during checkout.  Shipping from New Zealand, international orders welcome :-)
 

Offline jeroen79

  • Frequent Contributor
  • **
  • Posts: 529
Re: Arduino Calculator
« Reply #4 on: August 31, 2016, 04:39:30 am »
i want this to make a beep every time i press any button
You're still not asking a question, you just state what you want. ;)
Try formulating it like "How can I..." and add a ? at the end.

I'm not just trying to make fun of you.
If you want help then you will get it quicker if you put some effort in communicating what exactly it is you need.
For example, do you need help creating a beep?
Or with handling the buttom presses?
What do you have so far?
 
The following users thanked this post: tooki

Offline skillz21Topic starter

  • Frequent Contributor
  • **
  • Posts: 311
  • Country: au
Re: Arduino Calculator
« Reply #5 on: August 31, 2016, 05:18:47 am »
ok sorry about not explaining it properly. so how can i make a piezo buzzer to make a beep every time i press a button? what part of the code do i need to change?
 

Offline skillz21Topic starter

  • Frequent Contributor
  • **
  • Posts: 311
  • Country: au
Re: Arduino Calculator
« Reply #6 on: August 31, 2016, 05:22:55 am »
BTW, is it possible to use a I2C LCD? It can decrease the mess of wires.
 

Offline sleemanj

  • Super Contributor
  • ***
  • Posts: 3024
  • Country: nz
  • Professional tightwad.
    • The electronics hobby components I sell.
Re: Arduino Calculator
« Reply #7 on: August 31, 2016, 05:27:16 am »
ok sorry about not explaining it properly. so how can i make a piezo buzzer to make a beep every time i press a button? what part of the code do i need to change?

How about you start by making a piezo buzzer buzz using your Arduino.  The tone() Arduino function can accomplish this for you. 

~~~
EEVBlog Members - get yourself 10% discount off all my electronic components for sale just use the Buy Direct links and use Coupon Code "eevblog" during checkout.  Shipping from New Zealand, international orders welcome :-)
 
The following users thanked this post: BillyD

Offline skillz21Topic starter

  • Frequent Contributor
  • **
  • Posts: 311
  • Country: au
Re: Arduino Calculator
« Reply #8 on: August 31, 2016, 05:44:28 am »
ok sorry about not explaining it properly. so how can i make a piezo buzzer to make a beep every time i press a button? what part of the code do i need to change?

How about you start by making a piezo buzzer buzz using your Arduino.  The tone() Arduino function can accomplish this for you.
No offence but you can be very infuriating.
 

Offline george.b

  • Frequent Contributor
  • **
  • Posts: 383
  • Country: br
Re: Arduino Calculator
« Reply #9 on: August 31, 2016, 05:52:32 am »
No offence but you can be very infuriating.

You seem pretty lazy. No offense, of course.

:popcorn:
 
The following users thanked this post: ludzinc

Offline skillz21Topic starter

  • Frequent Contributor
  • **
  • Posts: 311
  • Country: au
Re: Arduino Calculator
« Reply #10 on: August 31, 2016, 05:57:03 am »
Ok so i have tried to connect to a I2C LCD. Here's the code. The two middle rows of the keypad won't work. Any idea why? also, disregard the info on how to connect the lcd to arduino. (sorry for any non professionalism)
 
The following users thanked this post: ludzinc

Offline skillz21Topic starter

  • Frequent Contributor
  • **
  • Posts: 311
  • Country: au
Re: Arduino Calculator
« Reply #11 on: August 31, 2016, 05:58:17 am »
And please don't judge my ability in writing code,  :( i am terrible at it.
 

Offline skillz21Topic starter

  • Frequent Contributor
  • **
  • Posts: 311
  • Country: au
Re: Arduino Calculator
« Reply #12 on: August 31, 2016, 06:07:35 am »
ok sorry about not explaining it properly. so how can i make a piezo buzzer to make a beep every time i press a button? what part of the code do i need to change?

How about you start by making a piezo buzzer buzz using your Arduino.  The tone() Arduino function can accomplish this for you.
So the thing is, i can make a buzzer buzz, i just don't know where to put that piece of code. the code for the calculator is complicated, so where do i actually put the buzzer code?
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12856
Re: Arduino Calculator
« Reply #13 on: August 31, 2016, 06:16:13 am »
Did you try reading the code?
Hint: there is a line commented // read keypad

Follow Sleemanj's advice, but beware: If no key is pressed,  you must avoid triggering the buzzer after a keypad read!
 

Offline skillz21Topic starter

  • Frequent Contributor
  • **
  • Posts: 311
  • Country: au
Re: Arduino Calculator
« Reply #14 on: August 31, 2016, 06:29:18 am »
Did you try reading the code?
Hint: there is a line commented // read keypad

Follow Sleemanj's advice, but beware: If no key is pressed,  you must avoid triggering the buzzer after a keypad read!
??? i tried that, here's the code
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12856
Re: Arduino Calculator
« Reply #15 on: August 31, 2016, 06:55:30 am »
Presumably you intended to start the buzzer with line 148:
Code: [Select]
    digitalWrite(8, LOW);and stop it at line 195 with:
Code: [Select]
    digitalWrite(8, HIGH);but line 195 is deep within a set of nested if() statements handling the 'D' key, so I suspect your buzzer is jamming on.

The end of the if(key != NO_KEY) block is actually at line 278:
Code: [Select]
          ++length;
        }
      }
   }  // << HERE (278)
}

/////////////////////Function Returns Modulo Even for Negative Numbers//////////////////////////
and that is where you'd want to either stop buzzing after a timer delay, or simply stop buzzing using an else for no key pressed.
 

Offline skillz21Topic starter

  • Frequent Contributor
  • **
  • Posts: 311
  • Country: au
Re: Arduino Calculator
« Reply #16 on: August 31, 2016, 07:03:14 am »
umm not sure what you mean...
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12856
Re: Arduino Calculator
« Reply #17 on: August 31, 2016, 07:20:32 am »
In that case, you need to learn how to program properly in C.  A copy of K&R and some practice writing console programs using a PC C compiler, will help considerably.  Technically Arduino code is written in C++, but most usrr programs stick to the 'vanilla' C subset of C++ and C is a lot simpler to learn than C++.

You'll also probably want to use a better editor than the Arduino IDE, as its brace matching is buggy and it doesn't support code folding so its a PITA to work with poorly structured programs with lots of multi-page flow control structures.
 

Offline skillz21Topic starter

  • Frequent Contributor
  • **
  • Posts: 311
  • Country: au
Re: Arduino Calculator
« Reply #18 on: August 31, 2016, 07:37:17 am »
ok, i am in the process of learning the c language already. but please can someone stop making this like a puzzle and actually tell me what i have to do??? |O |O if you don't want to come out and actually tell me what to do, don't reply to this post. >:( :horse:
 

Offline tatus1969

  • Super Contributor
  • ***
  • Posts: 1273
  • Country: de
  • Resistance is futile - We Are The Watt.
    • keenlab
Re: Arduino Calculator
« Reply #19 on: August 31, 2016, 07:54:46 am »
just read that piece of code you posted. this is very flat and basic C, it is very easy to read and could be a good starting point for your learning curve. You cannot expect to get an answer what to type where here, because the reason of most if not all people being here is the curiosity of how things are made up and tied together.
We Are The Watt - Resistance Is Futile!
 

Offline skillz21Topic starter

  • Frequent Contributor
  • **
  • Posts: 311
  • Country: au
Re: Arduino Calculator
« Reply #20 on: August 31, 2016, 08:02:47 am »
just read that piece of code you posted. this is very flat and basic C, it is very easy to read and could be a good starting point for your learning curve. You cannot expect to get an answer what to type where here, because the reason of most if not all people being here is the curiosity of how things are made up and tied together.
first of all, easy for you to say, you probably studied c in univirsity or something. secondly, r u saying people dont know the answer to my question? cause it seems like people like you know it pretty well. as i said, if you dont want to give an answer, then leave my thread.
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19514
  • Country: gb
  • 0999
Re: Arduino Calculator
« Reply #21 on: August 31, 2016, 08:07:55 am »
ok, i am in the process of learning the c language already. but please can someone stop making this like a puzzle and actually tell me what i have to do??? |O |O if you don't want to come out and actually tell me what to do, don't reply to this post. >:( :horse:
Solving puzzles is the whole point of programming. If you just want a calculator and don't want to figure it out then why not just go and buy one?

just read that piece of code you posted. this is very flat and basic C, it is very easy to read and could be a good starting point for your learning curve. You cannot expect to get an answer what to type where here, because the reason of most if not all people being here is the curiosity of how things are made up and tied together.
first of all, easy for you to say, you probably studied c in univirsity or something. secondly, r u saying people dont know the answer to my question? cause it seems like people like you know it pretty well. as i said, if you dont want to give an answer, then leave my thread.
The purpose of this forum is not to simply give out answers (although people often just do that) but to help you figure it out for yourself.
 

Offline skillz21Topic starter

  • Frequent Contributor
  • **
  • Posts: 311
  • Country: au
Re: Arduino Calculator
« Reply #22 on: August 31, 2016, 08:18:12 am »
ok, its clear that no one is willing to properly help me. does anyone know a different forum where i can actually get some solid answers?
 

Offline tatus1969

  • Super Contributor
  • ***
  • Posts: 1273
  • Country: de
  • Resistance is futile - We Are The Watt.
    • keenlab
Re: Arduino Calculator
« Reply #23 on: August 31, 2016, 08:41:35 am »
you probably studied c in univirsity or something.
Not exactly. Started this on my own in 1984 aged 15, using books and magazines that I bought from my pocket money. By the way, neither the internet nor eevblog existed then.
We Are The Watt - Resistance Is Futile!
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12856
Re: Arduino Calculator
« Reply #24 on: August 31, 2016, 08:42:36 am »
I also taught myself C, from the original K&R book back in '85, entering my code on an 8 bit home computer and compiling from tape using an integer only compiler.  Back then, unless you were studying computer science, you'd most likely be taught FORTRAN for a programming component of an engineering degree, and needing to pass a course for your grades is normally a very poor motivation for learning a programming language properly.

I pointed out what I believe to be the problem with your code and suggested where to turn the buzzer off to fix it.  As you haven't given a better description of the problems you are having other than 'don't understand' and 'doesn't work', there is little more we can do other than refer you to:

How To Ask Questions The Smart Way - Catb.org

Don't expect anything except total scorn from any programmers' forums if you cant frame your questions intelligently, and aren't prepared to dig into the code, manually trace its flow and hand annotate a listing of it till you understand it.  If you just want someone to code it for you, there are numerous sites that let you commission coding projects for money - if you don't mind a 3 or 4 figure USD bill.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf