Skip to content

Commit

Permalink
Merge pull request #32 from sourcebots/sb2024
Browse files Browse the repository at this point in the history
sb2024 arduino firmware
  • Loading branch information
WillB97 authored Aug 6, 2023
2 parents fe0cc8b + eab6c89 commit abb7f39
Show file tree
Hide file tree
Showing 4 changed files with 232 additions and 362 deletions.
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

0 comments on commit abb7f39

Please # to comment.