====== Coding: Raspberry Pi ====== In the introductory challenge, we are going to learn how to use the //turtle// library from the //Python// programming language to code some simple games. Later, we will use Python code to program a real-world light show (and a lot more) for our //Living World// project. * Sense Hat [[https://www.raspberrypi.org/blog/sense-hat-projects/|possibilities]] * MagPi [[https://www.raspberrypi.org/blog/experiment-with-the-sense-hat-in-the-new-magpi-essentials-book/|Essential Pi]]. Free PDF - [[https://www.raspberrypi.org/magpi-issues/Essentials_SenseHAT_v1.pdf|Raspberry Pi resource collection]] * View the Raspberry Pi Foundation [[https://curriculum.raspberrypi.org/|computing curriculum]] * About the [[https://opensource.com/life/16/9/coding-raspberry-pi-web-emulator|Raspberry Pi Sense Hat Emulator]] * Astro Pi [[https://astro-pi.org/missions/space-lab/faq/|FAQ]] === Image: Introducing Trinket - A Simple On-line Coding Emulator === [[https://trinket.io/help|Trinket]] is a browser-based, an all-in-one coding environment designed for education. Teachers and students use trinket to code during class. To enable 24/7 access from anywhere, students may create a free account on the Trinket website to save their work. === Getting Started === Learn how to make a dart board and digital darts: * https://trinket.io/challenges/bullseye.html Learn how to use code to program a turtle: * https://blog.trinket.io/getting-started-with-turtle/ Learn how to use code to decorate a tree: * https://trinket.io/challenges/holiday-tree.html Extension - Race the turtles: * https://codeclubprojects.org/en-GB/python/turtle-race/ Do plants and animals '//do social//'? * http://flipster.tv/doku.php?id=2018:living-world:home \\ ====== Light Detector ====== * Using a Light Dependant Resistor [[https://projects.raspberrypi.org/en/projects/physical-computing/12|(LDR)]] to monitor day and night * Reading analogue [[https://www.raspberrypi-spy.co.uk/2012/08/reading-analogue-sensors-with-one-gpio-pin/|RC time constant]] - [[https://www.circuitlab.com/circuit/hpwha3/raspberry-pi-light-dependent-resistor/|circuit diagram]]. * Using the [[https://gpiozero.readthedocs.io/en/stable/index.html|GPIOZero]] library. * Accurate [[https://www.raspberrypi.org/forums/viewtopic.php?p=871339|timing]] with pigpio ====== Sense Hat Module ====== The //Sense HAT// is an add-on board for the Raspberry Pi which was made especially for a space mission with British ESA Astronaut Tim Peake for Astro Pi. It's a great piece of hardware, very handy for data logging, science experiments, environmental analysis, games and more. It comes with a Python library making it work out-of-the-box. **[[https://opensource.com/life/16/9/coding-raspberry-pi-web-emulator|Read more...]]** The //Sense HAT// has many sensors, including magnetic field, position, movement, temperature, pressure and humidity, and can change its behaviour according to the values they report. The Sense HAT emulator has sliders you can move to change these values, so you can test how your code responds to environmental variables. Every student will have access access to their own, personal [[https://trinket.io/sense-hat|Trinket Sense-Hat Emulator]]. {{:brainbox:young-coders:sense-hat:sense-hat-trinket.png?360 |Trinket - Sense Hat Emulator}}{{ :brainbox:young-coders:sense-hat:sense-emu-500x315.png?310|Desktop Sense-emu}} \\ In case you do not want to use an internet-based emulator, there is an optional free [[https://www.raspberrypi.org/blog/desktop-sense-hat-emulator/|desktop version]]. Code written in the emulator is directly portable to a physical Raspberry Pi and Sense HAT without modification. This means students can now develop and test programs using the movement sensors and other modules from any internet-connected computer, anywhere in the world. * **[[https://projects.raspberrypi.org/en/projects/sense-hat-random-sparkles|BUILD A LIGHT SHOW]]** * Use basic programming constructs to create simple programs * Use basic digital, analogue, and electromechanical components * **[[https://pythonhosted.org/sense-hat/api/|Sense Hat API Reference all possible commands]]** * **[[https://github.com/raspberrypilearning/sense-hat-data-logger/blob/master/worksheet.md|Data Logger code example]]** * **[[https://opensource.com/life/16/9/coding-raspberry-pi-web-emulator|HOW TO USE A RASPBERRY PI SENSE-HAT EMULATOR]]** * **[[https://www.youtube.com/watch?v=MzMR_PYMCXE|DETAILED VIDEO TUTORIAL (17m)]]** * **[[https://astro-pi.org/resources/|EXAMPLE PROJECTS]]** \\ ====== 4 Channel Light Show Controller Device ====== Using the skills developed through the above exercises, students will learn how to program a device that will be used to control a lighting sequence of eventsi at school and later, at the Powerhouse Museum. === IRF 540 module - 4 Channel Opto Isolated DC Switch === {{:brainbox:young-engineers:raspberry-pi:irf540_mod_012.jpg?360 |}}{{ :brainbox:young-engineers:raspberry-pi:irf540_mod_013.jpg?360|}} \\ MOSFET's have good switching characteristics and are widely used to control almost any DC load. This 4 channel IRF540 MOSFET is perfect for switching DC loads up to 10A. The module is optoisolated - note that the GROUND connections are in common so there is not complete isolation. The module is basically a "Solid-State Relay" for DC. Up to 4 individually controllable loads may be connected to the (+) and (-) switched outputs, all fed from a common power rail. Being a low side switch, when the switch is on, it connects the load (-) terminal to ground. * Max Control Voltage (signal) : 6V * LED indicator for each channel * Chipset : IRF540 * Opto Isolator used : PS2801-4 * Max Switch Current: 10A (absolute max 33A with heatsink) * Max Switch Voltage: 100V \\