I am currently learning arduino and have started with the basics but i have what i think is a simple project but am struggling to find examples that i can work off. This is a simple layout of what i want the project to do
Starts with F1-F6 displayed in a list firstly in random order either on display or serial print
Then with the 6 inputs as the inputs (F1-F6) the first time it is pressed it takes that F number off the list and the second time it is pressed that F number appears on bottom:
Example list displays
F4
F2
F3
F1
F5
F6
F4 gets job so presses there input and list displays
F2
F3
F1
F5
F6
when F4 returns they press there button again and the list displays
F2
F3
F1
F5
F6
F4
Any help on the coding or where to look would be much appreciated
Starts with F1-F6 displayed in a list firstly in random order either on display or serial print
How? The values need to be stored in some sort of list, queue, stack, or array. You can't manipulate what has been displayed in the serial monitor.
Then with the 6 inputs as the inputs (F1-F6) the first time it is pressed it takes that F number off the list and the second time it is pressed that F number appears on bottom:
What are the inputs? Switches that people press? Switches that machines press?
F4 gets job
What job? How?
Keeping an array with values in it, removing values from the array, adding values at the end of the array, etc. are all relatively simple tasks.
Thanks for response. The way of storing the list is what i haven't been able to find. The F numbers correspond to a person who will receive the job manually and then press there button to take them off the list it is to keep track of who's turn is next once returning from a job at work.
int F1 = 6
int F2 = 7
int F3 = 8
int F4 = 9
int F5 = 10
int F6 = 11
;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600)
pinMode(F1, INPUT)
pinMode(F2, INPUT)
pinMode(F3, INPUT)
pinMode(F4, INPUT)
pinMode(F5, INPUT)
pinMode(F6, INPUT)
}
void loop() {
// put your main code here, to run repeatedly:
}
this is all i have so far as have completed some of the simple tutorials but none have really covered what i am attempting or maybe i haven't interoperated it correctly.
int F1 = 6
int F2 = 7
int F3 = 8
int F4 = 9
int F5 = 10
int F6 = 11
;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600)
pinMode(F1, INPUT)
pinMode(F2, INPUT)
pinMode(F3, INPUT)
pinMode(F4, INPUT)
pinMode(F5, INPUT)
pinMode(F6, INPUT)
}
void loop() {
// put your main code here, to run repeatedly:
}
You are missing a few of these: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Just cut and paste as needed.
So, the 'F' is unnecessary information. A byte array, of length 6 would be sufficient to track the worker numbers. A byte value, to keep track of the number of idle workers would be sufficient.
You'll want to look at the state change detection example, and the various button (stupid name) examples. You also need to tell us how the switches are wired.
It would be simpler to connect one leg of each switch to ground, and one leg to a digital pin, and enable the pullup resistor on the pin (pinMode(pinNum, INPUT_PULLUP);).
When a switch becomes pressed (or released) it is easy to see which employee number to add to the list (if it isn't in the list, added at the end, and increment the number of idlers) or remove it from the list (if it is there) (and move everything else up and decrement the number of idlers).
Thanks you make it sound so simple. Ill start looking at byte arrays. with that if for example 1 & 2 are on job so removed from list will it serial print the remaining 3-6 in order of who has job next if i ask it to? Which parts should cut and paste as needed? Thanks
You're describing behaviour in terms of a momentary pushbutton switch. This makes it harder to keep track of whether each person is available or not. I suggest you use either a toggle switch or a latching switch instead. Connect the switch between the digital input and ground, and enable the internal pull-up resistor. It would be nice (but not essential) to debounce the inputs. It would be a good idea to provide feedback for each input station so it's obvious what their status is being reported as. You can get latching switches with internal LEDs to show the status, or you could add an external LED to a latching switch or toggle switch.
The simplest way I can see to keep track of your list would be to number the inputs as you have done, and store the available numbers in an array. When a number becomes unavailable, loop through the array to locate the entry containing that number, and shift all the subsequent entries down one to remove that entry from the array - finally, zero the last entry (which is now unused). When a number becomes available, append it to the array.
It would be sensible to have a sanity check to make sure the number is not already in the array, for extra resilience
If you're using the serial monitor to display the status, then any time the status of any input changes you would print out the status of all entries.