Meals Selection Machine

by Moyue_Kaito in Circuits > Art

355 Views, 0 Favorites, 0 Comments

Meals Selection Machine

IMAG0473.jpg

It can help people who hardly select their meals. Press the start button then the machine will help you to decide what will you eat tonight. In addition, it can train the user to make decisions by themself. The following link shows how the machine works.

Design the Program

程式碼上.png
程式碼下.png

Use five LEDs and one switch to make the machine. Following the steps to control the shining order of the LEDs'.

Prepare Arduino

ardu pic.jpg

According to the program, connect the LEDs and the circuit.

void setup(){ // put your setup code here, to run once:
pinMode( 2 , INPUT); // sets the digital pin as input pinMode( 4 , OUTPUT); // sets the digital pin as output pinMode( 5 , OUTPUT); // sets the digital pin as output pinMode( 6 , OUTPUT); // sets the digital pin as output pinMode( 7 , OUTPUT); // sets the digital pin as output pinMode( 8 , OUTPUT); // sets the digital pin as output pinMode( random( 4 , 9 ) , OUTPUT); // sets the digital pin as output }

void loop(){ // put your main code here, to run repeatedly: if (digitalRead( 2 )) { for (int i = 0 ; i < 2 ; ++i ) { digitalWrite( 4 , HIGH ); // sets the digital pin on/off delay( 100 ); // waits a few milliseconds digitalWrite( 5 , HIGH ); // sets the digital pin on/off delay( 100 ); // waits a few milliseconds digitalWrite( 6 , HIGH ); // sets the digital pin on/off delay( 100 ); // waits a few milliseconds digitalWrite( 7 , HIGH ); // sets the digital pin on/off delay( 100 ); // waits a few milliseconds digitalWrite( 8 , HIGH ); // sets the digital pin on/off digitalWrite( 4 , LOW ); // sets the digital pin on/off delay( 100 ); // waits a few milliseconds digitalWrite( 5 , LOW ); // sets the digital pin on/off delay( 100 ); // waits a few milliseconds digitalWrite( 6 , LOW ); // sets the digital pin on/off delay( 100 ); // waits a few milliseconds digitalWrite( 7 , LOW ); // sets the digital pin on/off delay( 100 ); // waits a few milliseconds digitalWrite( 8 , LOW ); // sets the digital pin on/off } digitalWrite( random( 4 , 9 ) , HIGH ); // sets the digital pin on/off delay( 500 ); // waits a few milliseconds } else { } }

Decorate

2020-10-07 (2).png

Connect the LEDs to the extension cord. Then put it into the box and decorate it.

Finish