Biceps Training Machine

by Angus_Yin in Circuits > Arduino

167 Views, 1 Favorites, 0 Comments

Biceps Training Machine

IMG_20201004_223908.jpg
IMG_20201004_223751.jpg

用來訓練你的二頭肌,並且在完成指定次數時提醒。

Supplies

按鈕*2

LCD面板*1

電線*16

電阻*2

For Who :

IMG_20201004_223649.jpg
IMG_20201004_232755.jpg

給需要用啞鈴來練二頭肌的人使用,紙箱的長度剛好是一個手臂長。

Instructions for Use:

IMG_20201004_235554 (1).jpg

按下"Start"後,等待三秒即可開始,直到面板上出現"Complete"即可休息。

Initial:

IMG_20201004_232421.jpg
IMG_20201004_232430.jpg

#include

#include

int _Point ; // For these LCD controls to work you MUST replace the standard LCD library from... // https://github.com/marcoschwartz/LiquidCrystal_I2C // Direct download https://github.com/marcoschwartz/LiquidCrystal_I2C/archive/master.zip // Your project will not compile until this is done. LiquidCrystal_I2C lcd_I2C_27(0x27,16,2); // set the LCD address for a 16 chars and 2 line display

void setup(){ // put your setup code here, to run once: lcd_I2C_27.init (); // initialize the lcd lcd_I2C_27.backlight(); pinMode( 2 , INPUT); // sets the digital pin as input pinMode( 3 , INPUT); // sets the digital pin as input }

void loop(){ // put your main code here, to run repeatedly: lcd_I2C_27.setCursor(0 , 0) ; // set the cursor, counting begins with 0 lcd_I2C_27.print( "point:" ); // Print a message to the LCD. lcd_I2C_27.print( _Point ); // Print a message to the LCD. if (digitalRead( 2 )) { lcd_I2C_27.setCursor(0 , 1) ; // set the cursor, counting begins with 0 lcd_I2C_27.print( "Start:3" ); // Print a message to the LCD. delay( 1000 ); // waits a few milliseconds lcd_I2C_27.setCursor(0 , 1) ; // set the cursor, counting begins with 0 lcd_I2C_27.print( "Start: 2" ); // Print a message to the LCD. delay( 1000 ); // waits a few milliseconds lcd_I2C_27.setCursor(0 , 1) ; // set the cursor, counting begins with 0 lcd_I2C_27.print( "Start: 1" ); // Print a message to the LCD. delay( 1000 ); // waits a few milliseconds _Point = 0 ; lcd_I2C_27.clear(); } if (digitalRead( 3 )) { _Point = ( _Point + 1 ) ; } if ( _Point == 10 ) { lcd_I2C_27.clear(); lcd_I2C_27.setCursor(0 , 0) ; // set the cursor, counting begins with 0 lcd_I2C_27.print( "Done" ); // Print a message to the LCD. _Point = 0 ; } }

Result:

IMG_20201004_232421.jpg
IMG_20201004_232504.jpg
IMG_20201004_232514 (1).jpg

#include

#include

int _Point ; // For these LCD controls to work you MUST replace the standard LCD library from... // https://github.com/marcoschwartz/LiquidCrystal_I2C // Direct download https://github.com/marcoschwartz/LiquidCrystal_I2C/archive/master.zip // Your project will not compile until this is done. LiquidCrystal_I2C lcd_I2C_27(0x27,16,2); // set the LCD address for a 16 chars and 2 line display

void setup(){ // put your setup code here, to run once: lcd_I2C_27.init (); // initialize the lcd lcd_I2C_27.backlight(); pinMode( 8 , INPUT); // sets the digital pin as input pinMode( 4 , INPUT); // sets the digital pin as input }

void loop(){ // put your main code here, to run repeatedly: lcd_I2C_27.setCursor(0 , 0) ; // set the cursor, counting begins with 0 lcd_I2C_27.print( "Point:" ); // Print a message to the LCD. lcd_I2C_27.print( _Point ); // Print a message to the LCD. if (digitalRead( 8 )) { delay( 500 ); // waits a few milliseconds _Point = ( _Point + 1 ) ; } if ( _Point == 10 ) { lcd_I2C_27.clear(); lcd_I2C_27.setCursor(4 , 0) ; // set the cursor, counting begins with 0 lcd_I2C_27.print( "Complete" ); // Print a message to the LCD. delay( 3000 ); // waits a few milliseconds lcd_I2C_27.clear(); _Point = 0 ; } else { if (digitalRead( 4 )) { lcd_I2C_27.clear(); lcd_I2C_27.setCursor(0 , 1) ; // set the cursor, counting begins with 0 lcd_I2C_27.print( "Start:3" ); // Print a message to the LCD. delay( 1000 ); // waits a few milliseconds lcd_I2C_27.setCursor(0 , 1) ; // set the cursor, counting begins with 0 lcd_I2C_27.print( "Start: 2" ); // Print a message to the LCD. delay( 1000 ); // waits a few milliseconds lcd_I2C_27.setCursor(0 , 1) ; // set the cursor, counting begins with 0 lcd_I2C_27.print( "Start: 1" ); // Print a message to the LCD. delay( 1000 ); // waits a few milliseconds lcd_I2C_27.clear(); _Point = 0 ; } } }

Correct:

1.輸入腳位D2會跟LCD重疊到

2.加分的機制沒有延遲,導致分數連加

3.結束時沒有延遲,導致分數無法歸零

4.程式邏輯中沒有"否則",導致邏輯錯誤,使以上三點更難修復