Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

goal: 4 function calculator with equal button display numbers -999 - +999 last d

ID: 2988389 • Letter: G

Question


goal:
4 function calculator with equal button display numbers -999 - +999
last digit will be either negative or positive. when you press a button on the keypad it displays the number and if you press another it shifts the one over so it displays both, then when you press a function it clears and just shows the function, then you press another number and it clears once more and displays the number.

im literly about to give up i have been researching for a month now about shifting and multiplexing and i sort of understand it but i just cant code for my life! i am a very basic beginner like the only thing i can do is make lights flash and stuff. I am now down to my last resort, may someone be able to make the code and explain how everything works or walk me through this? please no links cause honestly i think i have visited every website related to this haha. please help!

Explanation / Answer

c right shift: >>
c left shift: <<
c add: +
c subtract: -
c multiply: *
c INTEGER or DOUBLE divide (depending on whether you use double or int): /
put 1 bit at position x: 1<<x

I suggest you use unisnged int and
typedef unsigned char uint8_t;
typedef unsigned int uint32_t;
or simply
#include <stdint.h>
using namespace std;

and use these unsigned types for data. get familiar with C before dealing with your arduino. in fact, get the simpler-to-install mingw from mingw.org and work your way up to working with mingw-w64.
the compiler is bing++.exe for mingw and tfor mingw-w64 it's got a long prefix to the filename. I use a batch file to do my compiling for me. others use make.

sorry, I can't make the ocde for you because I don't know the arduino, its architecture, or your circuit layout. but it sounds like fun. it is what was I was doing as a kit with my xerox computer. I made my own analog sound I/O card for a cp/m computer and started looking into signal processing FIR and IIR filters, wrote my own software for it and interfaced my card with a music package called music man (had to recompile it I think or soemthing), and tried various things for signal generation, FFT's, and that sort of stuff.
great fun.
a multiplexer chip basically does one of two things: you select from a set of individual digital signal lines to one output using a selector code, or the other way around, or, the mux simply downs one line of 16 (or 8, or 4, whatever, may be open collector) based on a binary selection code. usually these chips can also be enabled. that was in the days of TTL, if they still have those DIP chips (I hope so! - makes prototyping so much easier).

you need a number to bcd conversion routine. to me that's not hard. instead of using ascii characters you simply use BCD numbers. in your circuitry you need to use a BCD-to-7-segment converter, UNLESS you are direct-driving your display in a matrix fashion (which saves chips and .

using a timer interrupt to maintain your display will keep it running smoothly while you are simply doing your calculations: the timer-interrupt-handling display function would need to simply increment a counter to determine which column (display number) transistor to drive (because LED's draw too much current) , and which rows(segments) to drive at the same time. at most it will probably draw about 20mA*8=160mA. you will only require 9 digital lines for the display, and I don't know what your keyboard looks like. if it's a PC numeric keypad, those put out scan codes serially and I don't know much about them. it would be good to do some research on your keypad first to know what those codes ARE.

it would be a very good idea to keep a global array for that function which keeps your segments, however many digits you have should be the number of elements. and MAYBE your display function should even call an inline converter function to convert BCD values (numbers 0-9) and an optional decimal point parameter, into 7-segment format just to make things easier on you getting numbers into the display function.

that display function could also check keyboard scancodes maybe if timing is good.

all you would have to do is write your values to

reading from a matrix keyboard is easy. there should be pullup or pulldown resistors, pulling in the opposite direction of your data writes. for instance, if you write a 1, you should have a pulldown resistor on the rows. write a 1 that shifts into a data port which has the columns of your keyboard matrix hooked up to it, and read from the rows port and figure out which bit (hopefully only 1 is enabled) is on. wait until only 1 is on. don't read real fast,or you get keybounce (you might have to deal with that anyway).
from that, you interpret what key that is based on the row and column.