Thank you for your assistance, I will describe what I am attempting to do. And how I am trying to go about it. Perhaps just some specific directions may be helpful.
I am attempting to ‘build’ a basic animal training contraption. A LED lights up, A tone sounds, A dog is supposed to hit a lever with it’s paw to get a treat. Basic lab rat training.
I want have the option to make the dog hit the lever multiple times, multiple speeds, multiple wait times, etc…)
My first part is to get the electronics to work with the programming, then build the physical item. One step at a time.
I have been able to make each of the individual components work ‘almost’ as I want them to, but when I combine them, I get terrible results. I am certain it has to do with naming my constants and my variables in the right location and order.
It’s basic process is this:
I have a reset switch (resetSwitch - digitalPin 7) that sets all to a zero state.
A potientiometer (delayPot - Analog Pin A0) determines the ‘delayTime’
After the ‘delayTime’ the ‘pawLight’ (Red LED - DigitalPin 13) lights up and the speaker (spk1 - digital pin 10) give three low pitched tones (“Ready”)
In the first iteration;
If the dog presses the ‘pawButton’ (Digital Pin 6) one yellow LED lights up (Shift Register Qa)and the Speaker gives one medium pitched tone. (“Good First Step”)
Next Iteration:
After the ‘delayTime’ the ‘pawLight’ lights up and the speaker give three low pitched tones (“Ready”)
If the dog presses the ‘pawButton’ A SECOND yellow LED (Shift Register Qb) lights up and the Speaker gives one medium pitched tone.
This loop occurs for each of the 5 yellow LEDs and on the 6th (The Red LED) the speaker gives two short high pitched tones and activates “servo1” (DigitalPin 9) (which will release a treat) (“Good Dog”)
Then the system stops until I hit the ‘resetButton’ and I can at that time change the ‘delayPot’ to alter the time inbetween 'Ready"
It has three inputs:
resetSwitch – DigitalPin 7
delayPot – A0
pawButton – DigitalPin 6
and Four Outputs (One being the Shift register)
pawLight – DigitalPin 13
Spk1 – DigitalPin 10
Servo1 – DigitalPin 9
Shift Register –
Data - DigitalPin 2
Clock – DigitalPin 3
Latch – DigitalPin 4
5 yellow LEDs - (Shift Register - Qa – Qe)
1 red LED - (Shift Register - Qf
I have connected all the components to the Arduino using two breadboards using the aforementioned connections. I believe I have the proper resistors (7@330 ohm & 2 @10K ohm) and I believe it will work with the proper code.
A pic is here:
https://twitter.com/txeclipse/status/28 … 24/photo/1
How do I write it?
Start a sketch from scratch and drop in snippets? I’ve tried that and after about two snippets, it goes wonky.
Some other way? I’ve done a tiny tiny bit of programming so I do understand it is all a bunch of ‘If/Then/Else’ loops.
Any assistance would be most appreciated.