Microduino Altitude Lamp

来自Microduino Wikipedia
1304410487@qq.com讨论 | 贡献2015年2月9日 (一) 07:03的版本 Make a Lamp
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航搜索

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
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
USB cable 1 For connection
Li-on battery 2 Power supply
Goblet 1 Frame of the lamp
Lamp cover 1

Document

Program download: mpu_ws2812

3D module download:文件:3D-Ball.zip

Make a Lamp

  • Step 1: Prepare a goblet and a lamp cover, and set up the framework.
Table lamp cap.jpg
  • Step 2: Build hardware circuit
    • Equipment needed:
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.

Table lamp module.jpg
  • 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:
#define PIN 6

Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);

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:
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.

Table lamp 10dof module.jpg
  • Step 2: Build 3D module.

Adopt SketchUp to build 3D model according to hardware circuit buildup specification.

Table lamp 3D.jpg
  • Step 3: Adopt 3D printer to make the model and make sure the size is right.
Table lamp print.jpg

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).

  //=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);

Receiving end: Lighten the colored lights after receiving the data.

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);

Not receiving NRF data for two seconds, the colored light will be turned off.

  if(safe_ms>millis()) safe_ms=millis();
  if(millis()-safe_ms>2000)
  {
    colorWipe(strip.Color(0, 0, 0), 50);
  }

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.

Table lamp ok.jpg

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.