Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

sb2024 arduino firmware #32

Merged
merged 2 commits into from
Aug 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ MIT License

Copyright (c) 2017 Alistair Lynn, Thomas Leese
2017-2018 Jake Howard, Kier Davis, Peter Law
2018 Dan Trickey
2018-2022 Dan Trickey
2023 SourceBots

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
43 changes: 22 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,32 @@

The firmware for SourceBots' Arduino Uno board.

It communicates using commands sent over the USB serial pins.
It communicates using commands sent over USB serial.

Commands consist of a single character, followed by up to two arguments. The command is not separated from the first argument, but the first and second argument are separated by a space.

Request IDs can be specified by prefacing your command with `@int`, for example `@8335`. This is then returned with the command response and can be used to prevent race conditions.
Commands consist of a string terminated by a newline character (\n).
Commands consist of multiple parts seperated by a colon character.

## Commands

| Command | Description | Parameter 1 | Parameter 2 |
|---------|-----------------------------|--------------|------------------------|
| A | Read the analogue pins | | |
| L | Control the debug LED | State {H, L} | |
| R | Read a digital pin | Pin Number | |
| S | Control a servo | Servo Number | Width |
| T | Read a triggered pulse delay| Trigger Pin | Echo Pin |
| U | Read an ultrasound distance | Trigger Pin | Echo Pin |
| V | Get the firmware version | | |
| W | Write to a Pin | Pin Number | Pin State {H, L, P, Z} |
| Command | Description | Parameters |
|-----------------------------------|------------------------------|------------------|
| PIN:\<n>:MODE:GET? | Read pin mode | n = pin number |
| PIN:\<n>:MODE:SET:\<value> | Set pin mode | n = pin number, value=INPUT/INPUT_PULLUP/OUTPUT|
| PIN:\<n>:DIGITAL:GET? | Digital read pin | n = pin number |
| PIN:\<n>:DIGITAL:SET:\<value> | Digital write pin | n = pin number, value = 1/0 |
| PIN:\<n>:ANALOG:GET? | Analog read pin | n = pin number |
| ULTRASOUND:\<pulse>:\<echo>:MEASURE?| Measure range from ultrasound| pulse = pulse pin, echo = echo pin |

## Example Commands

Read the analogue pins: `A`

Turn on the debug LED: `LH`

Read the ultrasound distance: `U4 5`

Set pin 6 High: `W6 H`
Set pin mode to input and analog read pin
```
PIN:14:MODE:SET:INPUT
PIN:14:ANALOG:GET?
```

Set pin to output and set it high
```
PIN:2:MODE:SET:OUTPUT
PIN:2:DIGITAL:SET:1
```
Loading
Loading