Crazy Mouse

From Microduino Wiki
Revision as of 07:07, 30 October 2015 by 1304410487@qq.com (talk) (Created page with "{{Language| Crazy Mouse}} {| style="width: 800px;" |- | ==Objective== Beat the mouse and it will rush forward for some distance. ==Principle== Use Microduino-Shake sensor to ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Language: English  • 中文

Objective

Beat the mouse and it will rush forward for some distance.

Principle

Use Microduino-Shake sensor to detect the beat and let the motor lead the mouse run for some distance.

Equipment

Module Number Function
Microduino-CoreUSB 1 Core board
Microduino-Sensorhub 1 Sensor pin board
[[Microduino-Shake] 1 Vibration sensor
Microduino-Robot 1 Robot control board
Microduino-Motor 1 DC motor drive module
Motor 1 Motor

Hardware Buildup

  • Setup 1:Stack the CoreUSB, Robot, Motor and Sensorhub together.
  • Setup 2:Connect the vibration sensor to Sensorhub D2 and the motor to Stepper's OUTIA,OUTIB.

Software Debugging

  • Description for Control Pin Definition
#define PIN_SHAKE 2    //The vibration sensor input pin 
#define PIN_MOTOR 6    //Motor output pin
  • Judge if the vibration sensor is triggered. If yes, please control the motor and run it for three seconds after the trigger.
sensorReading = digitalRead(PIN_SHACK);    //Read the status of the vibration sensor. 
if(sensorReading == HIGH)
{
  digitalWrite(PIN_MOTOR,LOW);    //The motor works for three seconds.  
  delay(3000);
  digitalWrite(PIN_MOTOR,HIGH);
}
delay(1000);

Program

[MicroduinoCrazyMouse]

Result

By beating the mouse once, Microduino-Shake can detect vibration and the mouse will rush forward for three seconds.

Video