Linear SoftPot
Sensor
We used a Softpot Touch Sensor connected to P0 on the micro:bit. This sensor detects touch and gives a number between 0 and 1023, depending on where it is touched.
Outputs
The LED matrix on the micro:bit shows a line that changes position based on the touch sensor’s input. Since the LED display has 5 columns, we used Math.map() to change the sensor’s values (0-1023) into a 0-4 range so the line appears in the right column.
What We Learned
General
- Inputs: The softpot sensor gives different numbers based on touch position.
- Outputs:The LED matrix shows where the touch happened by lighting up a line in the matching column.
Programming Interface
- analogReadPin(P0): Reads the sensor’s value.
- Math.map(): Converts big numbers (0-1023) into small numbers (0-4).
- led.plot(x, y): Lights up a line on the LED screen.
- basic.clearScreen(): Clears the screen before showing the next dot.
- basic.forever(): Keeps the program running so the display updates constantly.
How It Works
- The sensor detects touch and gives a number between 0 and 1023.
- The program changes this number to match the 5 columns on the LED screen.
- The LED matrix lights up the correct column.
Links
Buttons
Sensor
Button P1: Cycles forward through colors.
Button P2: Cycles backward through colors.
Outputs
We can use the button to switch between the different animations.
- Rainbow Effect or Loop
- Color Change
- Pulse
What We Learned
General
- Inputs: The micro:bit buttons can be used to switch between different animations.
Programming Interface
- Handling Button Presses:input.onPinPressed detects button presses.
- Controlling a NeoPixel LED: Buttons can switch between different animations.
- Looping for Animations:The basic.forever() ensures the LED updates continuously.
and the basic.pause(50) controls the animation speed.
How It Works
- The micro:bit detects button presses on P1 and P2, changing animationMode.
- The NeoPixel LED changes color based on the mode.
- A fading effect is applied by changing the brightness.
- The loop continuously updates the LED over time.
Links
Make Code
GitHub
Servo
Sensor
We used multiple sensors in our micro:bit project, including Bluetooth for wireless commands, buttons for manual control, a sound sensor to detect loud noises, and an accelerometer to recognize tilting gestures. Each sensor provides input that the micro:bit processes to control outputs like servos, LEDs, and sound.
Outputs
The micro:bit responds in different ways depending on the input:
- Servo Motors: The servos connected to P1 and P2 move to different angles based on the input received.
- Sound: Pressing the buttons plays different melodies and the servo motors moves responding to the sound adding an interactive element.
What We Learned
General
- Inputs: The micro:bit can detect many types of inputs, including touch, tilt, sound, and Bluetooth.
- Outputs: We can control servos, display animations on the LED matrix, and play sounds in response to different inputs.
Programming Interface
- servos.P1.setAngle(x): Moves the servo motor to a specific angle.
- input.onButtonPressed(): Runs a function when a button is pressed.
- input.onGesture(): Detects tilt gestures and triggers actions.
- music.playDefaultBackground(): Plays background melodies when a button is pressed.
How It Works
- Pressing Button A plays the "Entertainer" melody and displays a heart icon, while Button B plays "Happy Birthday" with a message.
- The servo moves using its own sound as a loud voice and it looks likes it is dancing.
- Tilt the micro:bit left, and servo P1 moves to 0°. Tilt it right, and it moves to 180°.
- Touching the logo resets everything, setting both servos back to 0°.
Links
Make Code
GitHub