Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/instantiations/devday2022-demo-toit
Material used for RIoT Dev Day 2022 Demo
https://github.com/instantiations/devday2022-demo-toit
esp32 toit toit-language
Last synced: 29 days ago
JSON representation
Material used for RIoT Dev Day 2022 Demo
- Host: GitHub
- URL: https://github.com/instantiations/devday2022-demo-toit
- Owner: instantiations
- License: other
- Created: 2022-03-03T14:13:25.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-03-10T15:42:54.000Z (almost 3 years ago)
- Last Synced: 2024-10-23T20:12:41.791Z (3 months ago)
- Topics: esp32, toit, toit-language
- Homepage:
- Size: 336 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
RIoT Dev Day 2022 Demo
Toit Demo
Material used for [RIoT Dev Day 2022](https://riot.org/event/riot-developer-day-2022/) demo in the [Taking IoT Programming to a Higher Level](https://www.meetup.com/RIoT-NC/events/279446784/) presentation.
## Date and Time Logger Demo
Simple demo that prints the Date and Time into the console:
### dateAndTime.toit
```
main:
time := Time.now.local
print "Time: $(%02d time.h):$(%02d time.m)"
print "Date: $(%04d time.year)-$(%02d time.month)-$(%02d time.day)"
```## Traffic Light Demo
[traffic-light.toit](source/traffic-light/traffic-light.toit) and [traffic-light.yaml](source/traffic-light/traffic-light.yaml) contain a Toit demo of a physical traffic light.
### traffic-light.toit
```
import gpioclass TrafficLight:
redLight := gpio.Pin 14 --output
yellowLight := gpio.Pin 27 --output
greenLight := gpio.Pin 12 --outputON ::= 1
OFF ::= 0turnAllLightsOn: turnAllLights ON
turnAllLightsOff: turnAllLights OFFturnAllLights number:
allLights := [redLight, yellowLight, greenLight]
allLights.do: it.set numberprintAllLights:
print "Red: $redLight"
print "Yellow: $yellowLight"
print "Green: $greenLight"runSequence:
turnAllLightsOff
redLight.set ON
sleep --ms=2000
yellowLight.set ON
sleep --ms=1000
redLight.set OFF
yellowLight.set OFF
greenLight.set ON
sleep --ms=2000
greenLight.set OFF
yellowLight.set ON
sleep --ms=1000
yellowLight.set OFFmain:
trafficLight := TrafficLight
2.repeat:
trafficLight.runSequence
```### traffic-light.yaml
```yaml
name: "Traffic Light"
entrypoint: traffic-light.toit
triggers:
on_boot: true
on_install: true
```## License
- The code is licensed under [MIT](LICENSE).
- The documentation is licensed under [CC BY-SA 4.0](http://creativecommons.org/licenses/by-sa/4.0/).