This part of the series will be an application of the preceding part, which enabled our project to receive commands remotely via Bluetooth.
Table of Contents
- Requirements
- Implementation
- Connections
- Results
Requirements
- 1 x Raspberry Pi Pico board
- 1 x USB Cable type 2.0
- 1 x HC-05 Bluetooth module
- 10 x M-M jumper wires
- 2 x Mini Breadboards
In the
mainpart of the program, under the super loop, we need to check whether we are inautoormanualmode. We'll also need to enter a critical section since shared variables will be used.
Add handles for
uart_cmdanddirection.
CODEcortex_m::interrupt::free(|cs| {
let mut direction = DIRECTION.borrow(cs).borrow_mut();
let mut uart_cmd = UARTCMD.borrow(cs).borrow_mut();
if AUTO.borrow(cs).get() {
// Auto mode
} else {
// Manual mode
}
});
Then add the following under the
autoandmanualarms respectively:
CODEwriteln!(&mut serialbuf, "auto mode").unwrap();
transmit_uart_cmd(uart_cmd.as_mut().unwrap(), serialbuf);
writeln!(&mut serialbuf, "manual mode").unwrap();
transmit_uart_cmd(uart_cmd.as_mut().unwrap(), serialbuf);
Under
manualmode, we'll add the below code that applies our algorithm.
CODE// manual mode
match direction.as_mut() {
Some(Direction::Cw) => {
*direction = None;// reset direction
writeln!(&mut serialbuf, "manual mode: cw").unwrap();
transmit_uart_cmd(uart_cmd.as_mut().unwrap(), serialbuf);
},
Some(Direction::Ccw) => {
*direction = None;
writeln!(&mut serialbuf, "manual mode: ccw").unwrap();
transmit_uart_cmd(uart_cmd.as_mut().unwrap(), serialbuf);
},
Some(Direction::Up) => {
*direction = None;
writeln!(&mut serialbuf, "manual mode: up").unwrap();
transmit_uart_cmd(uart_cmd.as_mut().unwrap(), serialbuf);
},
Some(Direction::Down) => {
*direction = None;
writeln!(&mut serialbuf, "manual mode: down").unwrap();
transmit_uart_cmd(uart_cmd.as_mut().unwrap(), serialbuf);
},
Some(Direction::Zero) => {
*direction = None;
writeln!(&mut serialbuf, "manual mode: position zero").unwrap();
transmit_uart_cmd(uart_cmd.as_mut().unwrap(), serialbuf);
},
None => {},
}
Connections
The connections will remain the same as from the previous part of the series.
final copy.
In
manualmode the system responds appropriately to further commands.
Next we will set up our system to receive GPS data from the Neo-6m GPS module.
↗ Original-Artikel auf dev.to lesenVollständiger Original-BerichtAusführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.

SOCIAL SHARE CARD GENERATOR