📜 ⬆️ ⬇️

Arduino on car wash

Probably many have already seen self-service car washes. Is it possible to create such a device on the Arduino?


... the next wave of economic disasters ... will be the result of rapid automation that eliminates many good middle-class jobs ( B. Obama )

How it works


  1. The client comes to the car wash
  2. Contributes money through the bill acceptor (the amount is displayed on the display)
  3. Press the button of the necessary equipment
  4. The client is washing the car himself
  5. If desired, presses the stop, or selects other equipment.
  6. The board counts the amount for services (depending on the included equipment)
  7. When reset, the equipment turns off
  8. If necessary, repeat with paragraph 2.

At the same time, the network capabilities of the device allow:


Part of the equipment



Everything is purchased on Aliexpress (except bill acceptor and shield).
')

Assembly scheme


Network shild is just stuck on top. Then everything is going through it.

Arduino - Cashcode
A0-11 (TxD TTL)
A1 - 16 (RxD TTL)
GND - 4 (GND)

Arduino - MAX7219
A4 - CLK
A3 - CS
A2 - DIN
GND - GND
+ 5V - VCC

Arduino - Relay
2-7 - in1-in6
GND - GND
+ 5V - VCC

The buttons are assembled according to the voltage divider circuit and connected to the A5. I have resistors from 200Ω to 3.2KΩ.



Programming


Initialization of the board and relay:

#define DIN 16 #define CS 17 #define CLK 18 #define max7219_reg_decodeMode 0x09 #define max7219_reg_intensity 0x0a #define max7219_reg_scanLimit 0x0b #define max7219_reg_shutdown 0x0c #define max7219_reg_displayTest 0x0f const unsigned char alf[] = {0, 28, 34, 34, 34, 34, 34, 34, 28, 8, 24, 8, 8, 8, 8, 8, 28, 28, 34, 2, 4, 8, 16, 32, 62, 28, 34, 2, 4, 2, 2, 34, 28, 34, 34, 34, 34, 62, 2, 2, 2, 62, 32, 32, 60, 2, 2, 2, 60, 28, 32, 32, 60, 34, 34, 34, 28, 62, 2, 2, 4, 8, 16, 32, 32, 28, 34, 34, 28, 34, 34, 34, 28, 28, 34, 34, 30, 2, 2, 2, 28 }; void setup() { pinMode(DIN,OUTPUT); pinMode(CS,OUTPUT); pinMode(CLK,OUTPUT); digitalWrite(CS, HIGH); initLed(); pinMode(2, OUTPUT); pinMode(3, OUTPUT); pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); pinMode(7, OUTPUT); pinMode (A5, INPUT); } void setCommand(byte command, byte value) { digitalWrite(CS, LOW); for (int i=0; i<4; i++) { shiftOut(DIN,CLK, MSBFIRST, command); shiftOut(DIN,CLK, MSBFIRST, value); } digitalWrite(CS, HIGH); } void initLed() { setCommand(max7219_reg_scanLimit, 0x07); setCommand(max7219_reg_decodeMode, 0x00); setCommand(max7219_reg_shutdown, 0x01); setCommand(max7219_reg_displayTest, 0x00); setCommand(max7219_reg_intensity, 1); } 

Displaying the number on the scoreboard (the current value in case of power failure is stored in cells EEPROM 10 and 11):

 int printNumber(int add) { int n=EEPROM.read(10)+EEPROM.read(11)*256; if(add!=0) { n+=add; EEPROM.write(10, n%256); EEPROM.write(11, n>>8); } int k; for (char i=1; i<=8; i++) { digitalWrite(CS, LOW); for (char j=3; j>=0; j--) { k=n/pow(10,j); shiftOut(DIN,CLK, MSBFIRST,i); shiftOut(DIN,CLK, MSBFIRST,alf[i+(k%10)*8]); } digitalWrite(CS, HIGH); } return n; } 

Reading a button (keydown tracks the return of buttons to the original one to avoid relay bounce, numbers in conditions are chosen empirically):

 int key = analogRead (5); if(keydown && key<100) keydown=0; if((EEPROM.read(10)>0 || EEPROM.read(11)>0) && !keydown) { if(key>910 && key<980) setRele(1); if(key>810 && key<880) setRele(2); if(key>710 && key<760) setRele(3); if(key>550 && key<690) setRele(4); if(key>400 && key<500) setRele(5); if(key>330 && key<400) setRele(0); } 

Relay operation (in EEPROM cells 1-9 prices of services are stored per minute of use):

 void setRele(char r) { rele=r; keydown=1; for(char i=1;i<6;i++) digitalWrite(i+1, HIGH); if(rele) { digitalWrite(rele+1, LOW); timeRele=millis(); timeAllRele=60000/EEPROM.read(rele); } } 

Money counter (if the relay is on and the count of milliseconds exceeds the specified value, subtract 1):

  if(rele>0 && rele<=5 && (millis()-timeRele)>timeAllRele) { if(printNumber(-1)==0) setRele(0); timeRele+=timeAllRele; } 

Network client and server are taken from standard Arduino libraries. The bill acceptor works according to the CCNET protocol.

UPD:
Part 2 description of the work on the network and bill acceptor.
The next-generation device on the Orange Pi single-plate with a 7 "screen and a touchscreen .

Source: https://habr.com/ru/post/320458/


All Articles