Skip to content

Commit

Permalink
Docs project vs docs game (#23)
Browse files Browse the repository at this point in the history
* added picture, cleaner text

* removed useless empty lines
  • Loading branch information
baidarka authored Dec 14, 2023
1 parent 77a6210 commit be245f9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 27 deletions.
37 changes: 21 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,31 @@

## Intro

Speel jij het fantastische [Slag in de Rondte spel](https://www.slaginderondte.nl/spel) en mis je de vuurtorens?
Dan is dit jouw project!!
The board game '[Slag in de Rondte](https://www.slaginderondte.nl/spel)' is played on a map of the Dutch Wadden Sea.
This project lights up its lighthouses!

Imagine a map, with multiple lighthouses, that light up!
This repo contains MicroPython code to fade multiple LEDs independently.
![Slag in de Rondte extension](/img/slag-in-de-rondte-project-result-small.png)

The repo contains MicroPython code to fade multiple LEDs independently.
The fading patterns match real world lighthouse characteristics.
The board game uses a day and night cycle of 8 minutes.
The lighthouse LEDs follow this day/night cycle.
Written for, and tested on, [Raspberry Pi Pico](https://www.raspberrypi.com/documentation/microcontrollers/raspberry-pi-pico.html).

Written in MicroPython for Raspberry Pi Pico.
Inspired by the excellent board game: <https://www.slaginderondte.nl/spel>
The board game uses a day/night cycle of about eight minutes.
Switch off your room lights when the lighthouses come on.
And turn your room lights back on, when the lighthouses switch off.
(this day/night cycle can be bypassed)

![Board game Slag in de Rondte](/img/SlagInDeRondte-bordspel-small.jpg)

## Getting started

Make sure you can connect to your RPI Pico using your favorite editor.
E.g. Thonny or VSCode.
Get started with your RPI Pico: <https://projects.raspberrypi.org/en/projects/getting-started-with-the-pico>

### part 1

For lookenspeepers, build this project and watschen der Blinkenlichten!

- Wire up your RaspberryPi Pico according to the Fritzing diagram
- Wire up your Raspberry Pi Pico according to the Fritzing diagram
- (optional: ground GPIO2 with a resistor to bypass the 8 minutes day/night cycle and be 'always on')
- Save the script 'slag-in-de-rondte.py' to your Pico as 'main.py'
- Restart your Pico
Expand All @@ -34,14 +35,13 @@ YouTube [Slag in de Rondte, plain RPI Pico project](https://youtu.be/appXGaQrQTM

### part 2

After finishing part 1, optionally install the LED's in the game board.
After finishing part 1, install the LED's in the game board.

- Solder cheap speaker cable to the LEDs, to extend their connectors
- Gently punch holes in the game board at the 5 island lighthouses, and Harlingen Harbor
- Place the LED's in the board game
- Solder wires to connect the LEDs
- Use the red and green LED for Harlingen Haven
(when arriving at the harbor, the red harbor light is on your port side)
- Connect the LED wires to your board, replacing the LED's
(use the red and green LEDs at Harlingen Haven)
- Connect the LED wires to your breadboard as before
(do not change the circuit, leave the resistors in place)

YouTube [Slag in de Rondte, the complete game board install](https://youtu.be/sG-JDIeeyXA)
Expand Down Expand Up @@ -69,6 +69,7 @@ Tip: check for MicroPython linting
| resistor 1kΩ | 7 |
| breadboard | 1 |
| hollow pipe tool 4mm | 1 |
| speaker cable (thin) | 3 meters |

A [RPI Pico](https://www.raspberrypi.com/documentation/microcontrollers/raspberry-pi-pico.html)
costs about €6.- at [Kiwi](https://www.kiwi-electronics.com/nl/raspberry-pi-pico-h-10939),
Expand Down Expand Up @@ -103,3 +104,7 @@ I picked one up for €8.-. Possibly more on that later.

Feel free to contribute, in bite-size PR's. :)
Please be nice!

Sound? Listen in on [VHF Brandaris](http://www.tbandsma.nl/index.php/scanner/). :)
To all board players, seamen, skippers, schippers and Schiffer:
Fair winds and following seas!
Binary file added img/slag-in-de-rondte-project-result-small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 8 additions & 11 deletions slag-in-de-rondte.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#######################################################################
# Board game: Slag in de Rondte
# https://www.slaginderondte.nl
#
# https://github.com/baidarka/slag-in-de-rondte
# Project site: https://github.com/baidarka/slag-in-de-rondte
# Fade five LEDs independently.
# Fading patterns are the characteristics of five Dutch lighthouses.
#
# Tested on Raspberry Pi Pico with MicroPython 1.21.0.
#
# Author: @baidarka 2023
# An extension project for the Dutch board game: Slag in de Rondte
# https://www.slaginderondte.nl/spel
#
# Author: @baidarka, 2023
#######################################################################
from machine import ADC, Pin, PWM
from time import sleep
Expand Down Expand Up @@ -78,7 +77,7 @@ async def isophase(pwm, d):
Returns
-------
None
"""
"""
# Light on
for i in range(0, 100, 5):
pwm.duty_u16(round(i/100 * duty_max))
Expand All @@ -94,8 +93,7 @@ async def isophase(pwm, d):

# Coroutine
async def fade_out(pwm):
"""Fade out a LED, to stop the current task
"""
"""Fade out a LED, to stop the current task"""
# Get the current duty cycle and fade out from there.
current_duty_cycle = pwm.duty_u16()
current_duty_cycle_fraction = (current_duty_cycle // (duty_max/100))
Expand All @@ -108,8 +106,7 @@ async def fade_out(pwm):

# Coroutine
async def random_delay():
"""Random delay of at most 5 seconds
"""
"""Random delay of at most 5 seconds"""
max_msec = 5000
delay_ms = math.floor(random.random() * max_msec)
await uasyncio.sleep_ms(delay_ms)
Expand Down

0 comments on commit be245f9

Please sign in to comment.