3428| 4
|
[项目] 预防颈椎曲度变差 |
放假了。缺少了鞭炮陪伴,好多小朋友都在家看手机,看平板,时间久了,就会对颈椎带来压力,使得颈椎曲度变差。并最终影响健康。 这次这个项目就是试图从物理提醒的方式来改变人们的不良习惯。成品是用一个套在脖子上的柔性传感来实现的。如下图 当下巴前伸,触及并压迫到flex sensor到一定曲度。mp3模块开始报警:请注意姿势! 项目硬件清单: Arduino Uno DF MP3 module Flex sensor 先在脑子里打个草稿,程序要实现什么功能 设计电路图 写代码 [mw_shl_code=applescript,false]/*made by gada888 from Luoyang,China--Date-2020-01-18*/ unsigned char order[4] = {0xAA,0x06,0x00,0xB0}; int flexs = A0; // flex sensor is connected with pin A0 of the arduino int flexdata = 0; void setup() { Serial.begin(9600); volume(0x1E);//音量设置0x00-0x1E pinMode(flexs, INPUT); } void loop() { flexdata = analogRead(flexs); Serial.print("flex value;"); Serial.print(flexdata); Serial.println(""); if( flexdata > 220) { play(0x01);//指定播放:0x01-文件0001 delay(2000); } if( flexdata < 220) { delay(2000); } delay(1000); } //===============FUNCTION========= void play(unsigned char Track) { unsigned char play[6] = {0xAA,0x07,0x02,0x00,Track,Track+0xB3};//0xB3=0xAA+0x07+0x02+0x00,即最后一位为校验和 Serial.write(play,6); } void volume( unsigned char vol) { unsigned char volume[5] = {0xAA,0x13,0x01,vol,vol+0xBE};//0xBE=0xAA+0x13+0x01,即最后一位为校验和 Serial.write(volume,5); }[/mw_shl_code] 运行代码 实际运行效果图 |
4.3 KB, 下载次数: 848
© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed