hello everyone,
i purchased arduino uno , after discussions on project board think have figured out how works start writing own code. , since first time doing request assistance. have read "before post" messages , i'm not looking write code me. more or less follow along , guide me in mistakes make them. have parts (still waiting on china post send last item 7 segment display) , have made list of how code like. no code has been created yet. want pointers on preliminary objectives , if it's easy enough follow along. feedback accepted. thanks
here have far.
objective: variably strobe output.
input device0: momentary push button "debounced"
input device1: momentary push button "debounced"
output device0: output turning on , off @ preset time delays
output device1: 7seg display
code goals: push buttons move through pre-determined set of time delays
code starts @ "off" state 00 showing on display.
as input device0 pressed counts "up" next time delay
as input device1 pressed counts "down" previous time delay
once has reached "maximum" stops counting "up" , flashes display 4 times within 2000ms
once has reached "minimum" stops counting "down"
the "steps" should in order least most, steps include following values in time delay:
position duration display time
0 off 00 --
1 1 second on 5 seconds off 5- 5000
2 1 second on 4 seconds off 4- 4000
3 1 second on 3 seconds off 3- 3000
4 1 second on 2 seconds off 2- 2000
5 1 second on 1 second off 1- 1000
6 2hz 2 250
7 5hz 5 100
8 10hz 10 50
9 20hz 20 25
10 25hz 25 20
11 30hz 30 16
12 35hz 35 14
13 40hz 40 12
14 45hz 45 11
15 50hz 50 10
code call:
set buttona input pin
set buttonb input pin
set laser output pin
set var "holder"
set led dual 7segment dual display
var: holds count switches counts 0-15
check state of , down switch
if switch active add 1 var counter
if down switch active subtract 1 var counter
if var = 0 output off , display 00 on led
if var = 1 output on 1000ms , off 5000ms , display 5- on led
if var = 2 output on 1000ms , off 4000ms , display 4- on led
if var = 3 output on 1000ms , off 3000ms , display 3- on led
if var = 4 output on 1000ms , off 2000ms , display 2- on led
if var = 5 output on 1000ms , off 1000ms , display 1- on led
if var = 6 output on 250ms , off 250ms , display 02 on led
if var = 7 output on 100ms , off 100ms , display 05 on led
if var = 8 output on 50ms , off 50ms , display 10 on led
if var = 9 output on 25ms , off 25ms , display 20 on led
if var = 10 output on 20ms , off 20ms , display 25 on led
if var = 11 output on 16ms , off 16ms , display 30 on led
if var = 12 output on 14ms , off 14ms , display 35 on led
if var = 13 output on 12ms , off 12ms , display 40 on led
if var = 14 output on 11ms , off 11ms , display 45 on led
if var = 15 output on 10ms , off 10ms , display 50 on led
i purchased arduino uno , after discussions on project board think have figured out how works start writing own code. , since first time doing request assistance. have read "before post" messages , i'm not looking write code me. more or less follow along , guide me in mistakes make them. have parts (still waiting on china post send last item 7 segment display) , have made list of how code like. no code has been created yet. want pointers on preliminary objectives , if it's easy enough follow along. feedback accepted. thanks
here have far.
objective: variably strobe output.
input device0: momentary push button "debounced"
input device1: momentary push button "debounced"
output device0: output turning on , off @ preset time delays
output device1: 7seg display
code goals: push buttons move through pre-determined set of time delays
code starts @ "off" state 00 showing on display.
as input device0 pressed counts "up" next time delay
as input device1 pressed counts "down" previous time delay
once has reached "maximum" stops counting "up" , flashes display 4 times within 2000ms
once has reached "minimum" stops counting "down"
the "steps" should in order least most, steps include following values in time delay:
position duration display time
0 off 00 --
1 1 second on 5 seconds off 5- 5000
2 1 second on 4 seconds off 4- 4000
3 1 second on 3 seconds off 3- 3000
4 1 second on 2 seconds off 2- 2000
5 1 second on 1 second off 1- 1000
6 2hz 2 250
7 5hz 5 100
8 10hz 10 50
9 20hz 20 25
10 25hz 25 20
11 30hz 30 16
12 35hz 35 14
13 40hz 40 12
14 45hz 45 11
15 50hz 50 10
code call:
set buttona input pin
set buttonb input pin
set laser output pin
set var "holder"
set led dual 7segment dual display
var: holds count switches counts 0-15
check state of , down switch
if switch active add 1 var counter
if down switch active subtract 1 var counter
if var = 0 output off , display 00 on led
if var = 1 output on 1000ms , off 5000ms , display 5- on led
if var = 2 output on 1000ms , off 4000ms , display 4- on led
if var = 3 output on 1000ms , off 3000ms , display 3- on led
if var = 4 output on 1000ms , off 2000ms , display 2- on led
if var = 5 output on 1000ms , off 1000ms , display 1- on led
if var = 6 output on 250ms , off 250ms , display 02 on led
if var = 7 output on 100ms , off 100ms , display 05 on led
if var = 8 output on 50ms , off 50ms , display 10 on led
if var = 9 output on 25ms , off 25ms , display 20 on led
if var = 10 output on 20ms , off 20ms , display 25 on led
if var = 11 output on 16ms , off 16ms , display 30 on led
if var = 12 output on 14ms , off 14ms , display 35 on led
if var = 13 output on 12ms , off 12ms , display 40 on led
if var = 14 output on 11ms , off 11ms , display 45 on led
if var = 15 output on 10ms , off 10ms , display 50 on led
a few things.
don't try make whole project single item. break small parts , each part work separately before try bringing them together.
get project working serial monitor before try making it display on lcd. code lcd tends lengthy , can obscure other parts of logic. also, if need on forum easier test code using serial monitor.
do not use delay() function manage timing. use millis() illustrated in several things @ time.
the thread planning , implementing program tries illustrate idea of developing project description (such have posted) code.
...r
don't try make whole project single item. break small parts , each part work separately before try bringing them together.
get project working serial monitor before try making it display on lcd. code lcd tends lengthy , can obscure other parts of logic. also, if need on forum easier test code using serial monitor.
do not use delay() function manage timing. use millis() illustrated in several things @ time.
the thread planning , implementing program tries illustrate idea of developing project description (such have posted) code.
...r
Arduino Forum > Using Arduino > Project Guidance > First time writing code, please offer pointers.
arduino
Comments
Post a Comment