About SPICE |
SPICE Basics |
Running SPICE |
CIRCUIT COLLECTION
SPICE Commands |
SPICE Downloads |
About |
Contact |
Home
This code builds on our Initial Test Software by adding a pushbutton press to change the Vrange. Again, even though we have NO analog prototype built yet, we can still write code and run a basic PRE-TEST with the Arduino UNO Board by itself.
Check out the Software Design overview.
Back to Design Series
Here's the fast track version of running a C program (sketch) on your Arduino Board.
The schematic shows the physical world that the code can control to implement our meter.
Here's a shortened Flow Chart that skips the Pushbutton reading so we can focus on the ADC Read and Display.
A pushbutton as digital input requires only one additional component, a
pullup resistor.
The two states can be described as
SW Vdin Digital
Open 5V logic 1
Closed 0V logic 0
You read the button state every trip through the loop() function (or 0.25s) using digitalRead(Dx). The current and last reading are stored in variables
Although Normally Open, a press of the button causes a logic transition from 1 to 0. You can easily detect this change with the conditional statement
Arduino Pin usage
Caution Ahead - hardware person writing code! Granted, the program is so straighforward it's easy to create some reasonable code. However, I'm open to any suggestions from those with more Software experience.
The variable declararions occur before the setup() function.
This code excecutes once in the Arduino Sketch. Note how the Vrange is set and then the digital bits D12,13 are set for resistor divider switches SW1,2. See comments in gray for code description.
This code runs continuously. The main voltmeter tasks happen here. To write this function, simply follow the flow chart and write the C code for each block. See comments in gray for program description.
What can we test even though the analog circuitry has NOT been prototyped? Good news! We can jumper the Arduino's 3.3V supply directly into the A0 analog input.
Congratulations for travelling this far, the basic voltmeter code is complete! However, in order to fully test it, we'll need to start constructing the actual prototype..
Back to Design Series