查看“Microduino Altitude Lamp”的源代码
←
Microduino Altitude Lamp
跳转至:
导航
、
搜索
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
{| style="width: 800px;" |- | ==Outline== *Project: Microduino somatosensory lamp *Purpose: You can use Microduino-10DOF altitude sensor to have somatosensory control of a lamp. *Difficulty: High *Time-consuming: 4-Hour *Maker: Microduino Studio-YLB ==Principle== Here we adopt Microduino-nRF24 wireless communication. Microduino-10DOF first acquires altitude data and get it quantified to color value (0-255), and then send it to the lamp, which gets the value and lightens the lamp. The lamp adopts single-wire-bus WS2812 colored-light with built-in IC chip in each light, which can be freely controlled. ==Bill of Material== *Microduino Equipment {|class="wikitable" |- |Module||Number||Function |- |[[Microduino-Core]]||2||Core board |- |[[Microduino-USBTTL]]||1||Program download |- |[[Microduino-nRF24]] ||2||Wireless communication |- |[[Microduino-BM]] ||2||Battery management |- |[[Microduino-Lamp]] ||1||Colored light |} *Other Equipment {|class="wikitable" |- |USB cable||1||For connection |- |Li-on battery||2||Power supply |- |Goblet||1||Frame of the lamp |- |Lamp cover||1|| |} ==Document== Program download: [https://github.com/Microduino/Microduino_Tutorials/tree/master/Microduino_Advanced_Tutorial/mpu_ws2812 mpu_ws2812] 3D module download:[[File:3D-Ball.zip]] ==Make a Lamp== *Step 1: Prepare a goblet and a lamp cover, and set up the framework. [[File: Table lamp_cap.jpg||600px|center|thumb]] *Step 2: Build hardware circuit **Equipment needed: {|class="wikitable" |- |Module||Number||Function |- |[[Microduino-Core]]||1||Core board |- |[[Microduino-USBTTL]]||1||Program download |- |[[Microduino-nRF24]] ||1||Wireless communication |- |[[Microduino-BM]] ||2||Battery management |- |[[Microduino-Lamp]] ||1||Colored light |- |Battery||1||Power supply |} Stack all the modules together. [[File: Table lamp_module.jpg||600px|center|thumb]] *Step 3: Program test You will need _99_LCD_NeoPixel, which can refer to: [[Install Arduino IDE Microduino library support package]]. After the installation, just open “strandtest” program in the “Examples”. *Program description: <source lang="cpp"> #define PIN 6 Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800); </source> PIN defines the control pin of single wire bus light and “60” defines the quantity of the light. (Users can change that according to personal needs.) After the download, we can the fancy effect of the experiment. ==Somatosensory Remote-Control Buildup == Here we adopt a 3D-printed ball-shaped exterior. *Step 1: Build hardware circuit. **Equipment needed: {|class="wikitable" |- |Module||Number||Function |- |[[Microduino-Core]]||1||Core board |- |[[Microduino-nRF24]] ||1||Wireless communication |- |[[Microduino-BM]] ||2||Battery management |- |[[Microduino-10DOF]] ||1||Altitude detection |- |Battery||1||Power supply |} Stack all the modules together freely. [[File: Table lamp_10dof_module.jpg||600px|center|thumb]] *Step 2: Build 3D module. Adopt SketchUp to build 3D model according to hardware circuit buildup specification. [[File: Table lamp_3D.jpg||600px|center|thumb]] *Step 3: Adopt 3D printer to make the model and make sure the size is right. [[File: Table lamp_print.jpg||600px|center|thumb]] ==Overall Debugging== *Step 1: Program download Decompress program and open two programs respectively—one for sending and the other for receiving. *Program Description: Sending end: "mpu.h" is for subprogram of altitude detection. Microduino-10DOF acquires altitude data and then it is quantified to color value (0-225). <source lang="cpp"> //=The three lines below are angles between the three axis and the horizontal coordinate system, calculated by acceleration. Angel_accX=atan(Ax/sqrt(Az*Az+Ay*Ay))*180/3.14; Angel_accY=atan(Ay/sqrt(Ax*Ax+Az*Az))*180/3.14; Angel_accZ=atan(Az/sqrt(Ax*Ax+Ay*Ay))*180/3.14; Angel_accX_send=map(abs(Angel_accX),0,90,0,255); Angel_accY_send=map(abs(Angel_accY),0,90,0,255); Angel_accZ_send=map(abs(Angel_accZ),0,90,0,255); </source> Receiving end: Lighten the colored lights after receiving the data. <source lang="cpp"> Angel_accX=rec.rf_x; //Receive time sequence and sign values Angel_accY=rec.rf_y; Angel_accZ=rec.rf_z; Serial.print(Angel_accX); Serial.print(","); Serial.print(Angel_accY); Serial.print(","); Serial.print(Angel_accZ); Serial.println(""); colorWipe(strip.Color(Angel_accX, Angel_accY, Angel_accZ), 10); </source> Not receiving NRF data for two seconds, the colored light will be turned off. <source lang="cpp"> if(safe_ms>millis()) safe_ms=millis(); if(millis()-safe_ms>2000) { colorWipe(strip.Color(0, 0, 0), 50); } </source> Download to the corresponding hardware. Connect battery to the BM module, turn on the power switch on BM. Or you can adopt USB cable for power supply. Note: If cannot initiate the power after changing battery on BM, you need a USB cable to start that and move the ball to see lamp change. [[File: Table lamp_ok.jpg||600px|center|thumb]] ==Notice== *The sending and the receiving ends share one USBTTL, which is for program download. * If cannot initiate the power after changing battery, you need a USB cable to start BM. |}
返回至
Microduino Altitude Lamp
。
导航菜单
个人工具
创建账户
登录
名字空间
页面
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
Welcome
首页
创客大赛
大赛详情
3D打印
安装月球车
图形化编程
操控月球车
升级月球车
编程工具下载
软件下载
Arduino
Processing
Mixly
Scratch
模块套件
Microduino 102
mCookie 102
mCookie 202
mCookie 302
IBC
其他
应用套件
四轴飞行器
平衡车
小车CUBE
音乐播放器
刷卡音乐播放器
wifi气象站
彩虹音乐触摸灯
分贝检测仪
迎门汇报
LED点阵时钟
LED点阵屏幕
硬件
mCookie
Sensor
Microduino
MicroWrt
MicroNux
MicroRobot-Core
MicroRobot-CoreESP
ideaBoard
ideaBox
MicroMV
MicroAI
帮助
常见问题
帮助
工具
链入页面
相关更改
特殊页面
页面信息