Design Thinking Overview

When an individual first learns to use a particular piece of technology they generally look for a “recipe” type of approach.  In the T3alliance curriculum this looks like specific tasks or challenges that need to mastered.  Soldering a wire so that a button is able to function, or setting up a circuit so that an LED bulb works on a breadboard are examples of these types of tasks.  When your students are ready for something more, its time to introduce them to Design Thinking.

Design Thinking is a process that, when followed, leads to solutions that take into account the human experience.  Although the name design thinking and the movement that surrounds it has become popular during the rise of the Silicon Valley tech industry, at its core is the very old skill of empathetic listening and respectful problem solving.  In the T3 alliance program we use this process to facilitate student involvement in real world problems that have the potential for meaningful and impactful experiences.

The five stages of design thinking are described in this graphic.

The first stage of this process, empathize, is by far the most critical to the success of the process.  An instructor is always on the lookout for someone with a problem that is willing to ask for assistance in a way that gives a student interviewer a chance to understand the deeper human aspects.  The person with the problem can be considered a client if they meet some key criteria.  First, they know they are working with students and they agree to be kind and forgiving.  Second, they need to understand a little about the design thinking process and agree to be available to communicate with the student and maintain interest throughout the testing process.  Third they agree to appreciate the student for the effort they put into the process.

In a normal upbringing for a child this roll might be filled by a grandparent who knows just how to ask for help in such a way that a child embraces the challenge and is eager to talk about and receive praise after the task is completed.  The grandparent speaks to the child in a kind and loving way and knows that ignoring the child’s efforts will have negative consequences.  Most members of a community will be happy to fill this roll and will take it quite seriously.  Watch out for potential clients who are too busy, or ones that are such perfectionists that they want to do the work themselves.  Its assumed that if a student was ever working with a community member outside of a supervised environment, a background check would be completed.

Preparing a student for a positive empathetic interview experience involves preparing them with two levels of questions.  The first level is the basic 5 w’s of journalism.  Who are you, what is happening, when is it happening, where is it happening, and why is do they think it is happening.  This level of questioning has the potential to bring up a lot of useful information.  The second level is about digging a little deeper and uncovering how the client feels or would like users to feel in this situation.

The design thinking process guide that is produced by the Stanford design school is an excellent resource that goes through each stage in detail.  Here is a link to the design thinking process guide.

In the T3 alliance program we introduce the idea of a grant proposal as a stepping stone to building a prototype.  The mini grant proposal outlines the goals of the prototype, costs of the materials, the metrics for evaluation, and the deliverables (what they are responsible for reporting back) and is submitted to someone who ultimately signs off on the project’s costs.  This step can obviously be skipped when the prototypes involve only the use of inexpensive consumable materials.

Assembling the prototype with purchased materials is an heavy experience for many students.  There is a sense of responsibility and ownership that is healthy.  Its an opportunity to be communicative with team members and ask for help when its needed.   A poorly soldered electrical connection can cause lots of headaches further along in the process.

During the testing stage its a good idea to bring the client back in and experience the product or process design.  In some cases, refinement will need to occur, in others, it will be deemed successful.  A genuinely appreciative client will have a huge impact on a student’s sense of accomplishment.

This process is repeated as often as possible throughout the t3alliance program.  Each successful iteration of this process that a student engages in will engender a sense of efficacy and pride that will enable them to take on projects that require greater levels of collaboration with team members.

image_pdfGenerate PDFimage_printPrint

Selfie station example project

Here is an example of an applied design thinking project done with a class of 17 students at the University of Hawaii Hilo Upward Bound T³ Alliance during the summer of 2018.  Node Red and physical Raspberry Pi setup instructions can be found on this post.

Students had mastered the skills associated with basic physical computing and Node Red.  They were capable of setting up a button, an LED Ring, using a sonic sensor, a PIR sensor, and a small camera.  They had been able to combine all these components using Node Red and were capable of generating emails that sent a photo.

I asked around for a person or group at the university that might be interested in a device that could take photos and have them emailed instantly.    Eventually I found the perfect potential client in Shara Mahoe, the director of new student services.    She was planning a scavenger hunt for the new student orientation day later in the summer when 600 freshmen appear and nervously try to find their way around the large UH Hilo campus.  She listened to my description of what the students in our T3alliance program were able to do and how design thinking process worked.   Once she understood what was involved, she signed up to be a client.

Shara and a colleague showed up in my classroom the next day and I interviewed her in front of the class.  She described her day and what she hoped it would feel like to new students.  She listed out 5 locations around the University that could use a selfie station and asked my students if they could find a solution that would work.  I had previously broken the students up with an ice breaker activity and they now found themselves choosing one of the sites around campus to design a selfie station.  As a team, they discussed what they had heard Shara speak about and filled out the first section of the guide questions associated with the “empathy” stage of the design thinking process.

We took a quick walking field trip to each location and the students finished the “define” phase, where they articulated exactly what was needed and what the constraints were, and moved into a brainstorming “ideation” phase.  Students were tempted to think there was just one type of solution to the selfie station problem, but they sketched out three different ideas. When this was finished they chose a “prototype” design they wanted to build and they wrote out a mini grant proposal.  

When the proposal is complete, we submitted it to the Upward Bound director for approval.  We prepared ahead for this type of project with wires, and buttons and extra raspberry pi devices with cameras and power supplies.  After the proposal was approved we handed out and checked off the items that had been requested on each proposal. The students got right to work building the prototype selfie stations.

We instructors restrained ourselves from helping too much and let the teams figure out how to build their designs.  When students would ask for help, we would respond with a question.  Eventually, the students learned to frame their questions in such a way as to be able to google the answer.  We helped in the areas where a skill had not been introduced, such as soldering, or learning to “remote” into the pi.  The teams were responsible for building the prototype, writing the code that controlled it, and recording and editing a short video.

Several days later, Shara met with us to see the results. The students walked around the campus with her demonstrating the way their selfie stations worked and noting what things could be improved. One team had an opportunity to radically modify their design because it didn’t take into account the safety considerations necessary when a crowd of students would moving past a certain area.

The students were beaming when Shara thanked the group.  She appreciated their efforts and asked them to sign their work so that new students at the school knew who had built these stations.  Each group modified and perfected the design and the instructions.

As part of the initial mini grant application, The teams had been responsible for writing user instructions, making a video about the project and writing a short report about the progress of the project. 

image_pdfGenerate PDFimage_printPrint

Hawaii Eruption Update

Aloha all,                                                                                                            June 29th, 2018

Its time for another update on the eruption in Hawaii.   

We are at about 50 days since the eruption began, and there does not seem to be an end in sight.  Since the last update lava has been pumping out of the main fissure in the Leilani Estates subdivision and forming a river of fast moving pahoehoe lava all the way down to the ocean.  When the wind is going in the right direction, residents of a neighborhood where we once lived (when we first moved to Hawaii in 2011) are able to walk close to the river and marvel in its awesomeness. There are some amazing things to see geologically – this lava lava boat phenomenon is awesome.  The chunk of lava you see in the photo below is moving down the river of lava. 

Its not open for tourism, and if you aren’t a resident, you can be arrested for being out there.  The Hawaii Civil Defense is understandably concerned about public safety.

Tourists have been taking a lot of helicopter rides, and boat rides to see the lava where it is entering the ocean.  Here is a video of what the ocean entry looked like a few days ago.

Sometimes amazing things are seen in the boat – this is a Lavaberg that was caught on video.  I am somewhat baffled how this happens.  I have a piece of the light reticulite lava collected from Leilani Estates that floats on water, but this is likely a dense block of pahoehoe.  I suspect the heat of the rock is great enough to vaporize the water underneath and cause a buoyancy that will last as long as the bubbles keep forming.  I would love to have had a chance to observe this until it sunk,  or even better observe it with a remote underwater rover!

The school where I once taught science, Kua O Ka La, is on the verge of being covered by lava.  I met with the school principal last week and we filmed an interview with her and one of the teachers who lives in an area just a mile south of the main eruption.  The students I work with in the T3 alliance Upward Bound summer program at UH Hilo are working on building deployable air quality monitoring stations that can report information in real time on a website.

Deanna, the preschool teacher in this video has been living in the basement of our home in Hilo since the eruption began. Since this video was recorded, FEMA has changed the classification of her property to uninhabitable and opened up the possibility for her and her husband to receive federal assistance.   She and her husband represent the type of families that inhabit much of this area.  They own their property outright, and have lovingly worked the land so that they could survive and raise a family on one income. Susie, the principal in the video, had a beautiful home in Leilani Estates that was destroyed by lava.  She had paid the high cost of insurance for a home in lava zone one (lava zones are a way that the insurance companies rate risk for lava… 1 is high risk, 5 is the lowest risk) for years only to find out that the insurance company has fine print clause requiring that the owner prove that the home burned before it was covered by lava.  Because she doesn’t have a photo of the home on fire she is out of luck.

Emily has continued to volunteer as a counselor at the shelters on the weekends and has heard these kinds of stories often.  Food and materials are still being provided at the shelters but there is a sense of unease about the future that is gnawing at the community.  FEMA and the Red Cross estimate that close to two thousand individuals have been displaced.  The lack of housing and the huge economic impacts associated with this eruption are driving out those have the ability to leave.  Those that are left are dealing with limited housing options, bleak prospects for work, and the daunting task of dealing with rebuilding their lives with the relatively small allotments that FEMA is able to provide.    

Heart wrenching stories appear on facebook of small businesses, or individuals that have lost everything and are trying to find what it takes to make their next steps.  I am sure that there are even more stories out there that haven’t been written down.

When I asked the 17 students in my class this past week how many of them had a direct family connection to someone that had been affected by the eruption, about half raised their hands.  They have taken on the task of building these sensors with a vigor that is uncharacteristic of most teens.  We met with a chemist at the department of health and they peppered him with questions about air quality and how it can be reliably measured.  They helped outline tasks and a timeline and and are diligently working to have a prototype ready for testing early next week.  If tests go well, they are preparing to go into production mode and have sensors set up at schools and in communities around the island by the end of the following week. Summarizing the project and educating the public on the meaning of the data with short clear videos will be the task for the last week of the summer program.

This is an audacious plan, but its exactly the kind of project that the T3 alliance program was designed for.  Funded by a grant from the National Science Foundation, the program teaches students to use emerging technologies to address community based problems.   Upward Bound programs receive kits and a curriculum with access to “soft money” that can be allocated as needed.   UH Hilo Upward Bound and the T3 alliance program agreed to help with any additional funding needed to make this project work.   The air quality sensors are being built with supplies that can be bought at Home Depot and 35 dollar Raspberry Pi’s. With all the sensors and components included, we are looking at something in the range of two hundred dollars.

I humbled by the students and the incredibly talented team of instructors that are working on this project with me.  We are about to begin posting updates on social media and via the t3alliance.org website as to the progress of the project. Please give their posts a thumbs or a few words of encouragement.

With luck their story will inspire other students and to step into their potential roles as engaged problem solvers in their communities.  Success here for these kids may mean that they have the efficacy and drive to teach and help others make their world a better place.

image_pdfGenerate PDFimage_printPrint

RPi Node-Red Auto Start

When deploying a Raspberry Pi as a permanent/semi permanent installation is will be useful to have Node-Red start persistently, in the case of power failure, etc.

Open a terminal and paste the following command

sudo systemctl enable nodered.service

Now Node-Red will start automatically when the Raspberry Pi boots up.

image_pdfGenerate PDFimage_printPrint

(Archive) RPi Node-Red: DHT11 Temperature and Humidity Sensor

Please wire up your DHT11 sensor as below:

To be able to use the DHT11 temperature and humidity sensor we will have to install the Node-Red node and the BCM2835 library to support it, the easiest way is explained below.

First open a terminal  window and copy and paste the entire code block and press enter.

#install bcm2835 library
cd ~/
curl http://www.airspayce.com/mikem/bcm2835/bcm2835-1.56.tar.gz > bcm2835-1.56.tar.gz
tar zxvf bcm2835-1.56.tar.gz
cd bcm2835-1.56
./configure
make
sudo make check
sudo make install

#install node
cd ~/
sudo npm install --unsafe-perm -g node-dht-sensor
sudo npm install --unsafe-perm -g node-red-contrib-dht-sensor

After the commands finish running press enter again to make sure the last one has been run.

Restart your raspberry pi, start Node-Red and search for “dht” you should find a node called “rpi dht22” this indicates that the node has been installed correctly.

The node must be setup as in the below image – make sure you select DHT11

image_pdfGenerate PDFimage_printPrint

Evaluation

Hello T3Alliance Directors,
As your summer programs get up and running, we need you to identify a group of students within your Upward Bound program to be used as a comparison group to the T3 Alliance students. (I’ve cc’ed instructors here too in case it helps!)
Please select about the same number of students with a similar background and provide those names to the proper individual who can forward the survey link to the selected students. This comparison group will take the SOAR survey at the same time as the T3 Alliance students – both at the start and end of their UB program. The comparison group can come from a similar school or have a similar demographic distribution based on ethnicity, socioeconomic status, age, etc. It does not matter what the comparison group is doing within their UB program or if they have the same instructor as the T3 Alliance students. The comparison group will be used in order to understand long-term goals of the T3 Alliance project.
You will be sent a separate link for the comparison group students to share with the instructors. Please find attached the consent form/information letter specifically for the comparison students. They are taking the same SOAR survey but have the T3Alliance logo and title removed. Follow the same instructions for the survey with both the T3Alliance students and the Comparison students.
Please refer questions specifically on the comparison group to Barbara on the evaluation team.
Thanks,
The Evaluation Team
image_pdfGenerate PDFimage_printPrint

RPi Node-Red: Sonic Sensor (HC-SR04)

Goal:

Read distance measurements from the sonic sensor within Node-Red

What You Will Learn:

  • Basic Circuit Prototyping
  • Basic Node-Red Programming

What You Need to Know:

Parts List:

HC-SR04 Ultrasonic Range Finder

4x Female – Female Jumper Wires

What is a Sonic Sensor?

It is a sensor that works based on the principles of echo location.  The sensor is able to emit ultrasonic pulses and read ultrasonic pulses, using this timing information along with the speed of sound and some math we can extrapolate distance to the surface the pulses have reflected against.

\text{distance} = \frac{\text{(time)}\text{(speed of sound)}}{2}

Thankfully the node we will be using will take care of the math for us.

Getting Started:

Setting up the Hardware

I would suggest wiring it exactly as it is in the diagram, using 4 female to female jumper wires to allow you to point the sensor around freely.

Setting up Node-Red

Start Node-Red and navigate to 127.0.0.1:1880  using the web browser.  Drag the “rpi srf” node and a “debug” node into the flow area.

Double click the “rpi srf” node to open its configuration settings.  Set Pins to “16,18” (which corespond to GPIO 23,24).  The programmer of this node decided that it was better to use the Raspberry Pi’s board pinout rather than the BCM standard, this web page shows both.

Next, open the “debug” nodes configuration settings.  Check the debug window and node status options.  This will display the last sent message beneath the debug node.

Link the nodes together and deploy the flow.

If everything has gone together properly, you should get numbers appearing below the “debug” node.  These are distance measurements in centimeters, you can change the frequency of the measurements within the “rpi srf” node or see the entire measurement history in the debug tab.

image_pdfGenerate PDFimage_printPrint

RPi Scratch 2 + GPIO Introduction

Goal:

Using a button control a sprite within Scratch 2 and then to turn an LED on and off.

What You Will Learn:

  • Control the GPIO with Scratch 2
  • Wire a button with a pull down resistor

Parts List

  • Breadboard
  • Push Button
  • 10k Ohm Resistor
  • 1k Ohm Resistor
  • LED
  • Some Jumper Wires

What is a Breadboard?

A breadboard is a prototyping platform that allows the easy creation of circuits without having to solder.  Each row of the breadboard is connected internally (not across the middle break). This mean that putting something into position 1a and 1b connects them electrically together while something plugged into position 1a and 2a are electrically isolated.  

The power rails on the left and right hand side of the breadboard are connected in a column and can be an easy way to access ground of power if you choose to route it there.  The color red and by extension the red column is often used for power while blue is often associated with ground and thus used for a ground connection.

What is a Resistor?

A resistor is an electrical component that has a specific value of resistance measured in ohms.  Resistors are used to restrict the amount of current in a circuit or facilitate a drop in voltage.  Its value of resistance can be read in ohms using the colored bands on the body of the resistor.

What is an LED?

An LED is a light emitting diode.  Diode’s are a class of electronic components that are designed to only allow current to pass through them in one direction.  This means that LEDs are polar meaning they have an anode (positive) and a cathode (negative). Current must flow into the anode and the cathode must be attached to ground.  

There are several methods of identifying the anode and cathode:

Look at the lengths of the pins, If the LEDs’ pin have not been modified the longer pin is the anode and the shorter pin is the cathode
Look at the sides of the LED a portion of the case will be flat the pin on that flat side is the cathode
Look inside of the bulb, each pin is connected to a flat piece of metal internally.  The pin that is attached to the larger piece is the cathode
An LED must have a current limiting resistor between it and ground or between it and power.  An unprotected LED will pull more and more current until it burns itself out. The value of the resistor will have an effect on the LEDs’ luminosity.  The higher the value of resistance the resistor has the less current will get to the LED and thus the dimmer the bulb will shine. The amount of current can be calculated in milliamps with Ohm’s Law, using the value in ohm’s for resistance

\text{current} = \frac{\text{voltage}}{\text{resistance}}

Getting Started:

Setting up the Hardware

When placing the button in the breadboard make sure that the pins are securely placed, it can be difficult.  Also note that the kinked leg of the LED in the diagram refers to the anode (positive) pin.

Setting up Scratch 2

Click on the Raspberry Pi icon in the upper left corner of the screen, click on Programming look for the cat icon and then click on Scratch 2.

Once the  Scratch 2 window opens click on More Block and then Add an extension.

Click on Pi GPIO to select it and then click on OK.

Now that we’ve added the blocks we need to communicate with the GPIO, Click on the Events tab and drag the “When flag clicked” block into the block area on the right hand side of the window.  

Click on the More Blocks tab and “set gpio __ to __” blocks to the “when flag clicked” block.  Fill in the blanks with 25 to input.

Next click on the Control tab and add a “forever” block to the bottom of the program.

Staying within the Control tab place an “if __ then” block inside of the “forever” block.

Next click on the More Blocks tab, place the “gpio __ is high?” block inside the “if __ then” block (place the left edge inside the hexagon).  Fill in the blank with 25.

Click on the Looks tab and place the “say Hello! For 2 seconds” block into the body of the “if __ then” block.

This is now a complete program, if you click on the green flag to start it, when you press the button on your breadboard the sprite will say “hello” for two seconds.

Now let’s also control the LED with the button as well.  Click on the More Blocks tab and drag a “set gpio __ to __” block above the “forever” block.  Fill in the blanks with 12 and output low.  This ensures that the LED will be off when the program starts.

Place a “set gpio __ to __” block before the “say Hello! For 2 seconds” block and one directly after.  In the first block fill in 12 and output high, in the second block fill in 12 and output low.

Now if you activate your program by clicking the flag, the button should activate both the sprite and blink the LED.

Whats Next?

  • Can you change the duration of the hello message and LED activation?
  • Can you make the LED blink a second time per button activation?
image_pdfGenerate PDFimage_printPrint

RPi Minecraft Cannon

Goal:

Using Minecraft’s API and the Python programming language, spawn a cannon that’s orientation and launch trajectory can be adjusted in real time.

What You Will Learn:

  • Introduction to Github

What is GitHub?

GitHub is an online repository that offers version control.  It is most often used for computer code and interacted with using a command line tool called git.

Getting Started:

Open a terminal either using the icon or the keyboard shortcut CTRL+ALT+t.

When opening the terminal like this we are placed in the home directory.  In RPi: Minecraft + Python Introduction we created a directory named code in the home directory.  We will now navigate into that directory using cd (change directory). Enter the following into the terminal.

cd code

You may have noticed that the prompt that was previously

pi@raspberrypi:~ $

Has now become

pi@raspberrypi:~/code $

It is informing you of the directory you are currently in, also known as the current working directory.  Remember that ~ (tilde) refers to the home directory.

 

Now that we are in our code directory, lets use git to download the cannon code from this GitHub repository

git clone https://github.com/martinohanlon/minecraft-cannon.git

Now the code has been cloned from the specified github repository into the current working directory.  Lets inspect ours with the ls (lists all files and directories)

ls

You should notice that a new directory “minecraft-cannon” has been created.  Lets navigate into the directory using cd and then inspect the contents using ls

cd minecraft-code

ls

There are several files and directories here, feel free to explore them using cd.  

Note that,

cd ..

will move your current working directory “up” one or backwards into the directory containing the current directory.

At this point we need to launch Minecraft and get into a game.

Once Minecraft is open, click Start Game then join a preexisting world or Create New.  

Back in the terminal we want Python to execute the “minecraft-cannon.py”.  If you left the directory we downloaded with git you can get back there with the following

cd ~/code/minecraft-cannon

Then,

python minecraft-cannon.py

this instructs the Raspberry Pi to use Python to run the “minecraft-cannon.py” file.

Your prompt in the terminal should have changed to

Stuffaboutcode.com Cannon >>

You can now use the following list of special commands to create, aim and fire a cannon in the running Minecraft game.

  • start
  • rotate [0-360]
  • tilt [0-90]
  • fire
  • exit

Start  spawns a cannon, exit an active cannon.  Using start multiple times in a row will construct multiple cannons however only the most recently made cannon can be controlled with the other commands.  You do not need to include the square brackets when typing the commands. 

Whats Next?

  • RPi: Minecraft Clock
  • RPi: Minecraft Snake

Article adapted from source

image_pdfGenerate PDFimage_printPrint

RPi Minecraft + Python Introduction

Goal:

Interact with Minecraft using the Python programming language and Minecraft’s application programming interface(API).

What You Will Learn:

  • Basic Python Programming
  • Use of the Minecraft API

What is an API?

To put it simply an API is a well defined method of interacting with some kind of software.  Think of it like the rules to a game, the rules dictate how the game is played and how you are able to interact with the game state.

What is Python?

Python is an interpreted programming language that is designed to be easy to learn and easy to use.  Python has many available libraries for the Raspberry Pi and is a very useful tool on the platform. Keep in mind that python uses white space (spaces, tabs, etc) to format and organize it’s instructions, take close care when typing to avoid these sometimes unobvious mistakes.

Getting Started:

Open a terminal either clicking the icon on the top bar or using the keyboard shortcut CTRL+ALT+t.

We are going to make a folder to store help organize the code we will be writing.  Enter the following into a terminal

mkdir ~/code

The mkdir command creates a new directory at the specified location, in this case “~/code”.

The “code” directory is created at the “~/” location ~ or tilde is a shortcut for the home directory.  We can verify the success of the command by entering

ls

In the terminal (this command lists all files and directories), or using a file explorer.

Next, open Thonny Python IDE by navigating to the Raspberry Pi icon in the upper left side of the desktop, click on Programming  and look at the bottom of the list for Thonny Python IDE.

Click on File and select New.

Click on File and Save As “minecraft_python.py” in the code folder we created earlier(/home/pi/code).

Now we are ready to start programming in Python.

Into your empty Python file type

import mcpi.minecraft as minecraft
import mcpi.block as block
from time import sleep

The “import” keyword load a specific code module.  The “as” keyword allows you to rename a code module to something else.  The “from” keyword allows you to load a submodule as it’s own module.

Currently this python program does nothing exciting however lets learn how to execute the program. You can either use they keyboard shortcut F5 or click on the green play icon.

After program execution the shell at the bottom of the window should have some lines of text appear, however nothing should else should happen.

Now type the following into your program

mc = minecraft.Minecraft.create()

mc.postToChat("Hello, world!")
sleep(5)

The first line creates an object that is connected to running an instance of Minecraft.  Setting it equal to mc lets us access the Minecraft game using mc within the code. The second line uses the mc object and a method “postToChat” to send text to the games chat.  The third line delays the program for the specified number of seconds, in this case 5 seconds.

Before running the code this time, we need to open Minecraft and enter a new world.  Click on the Raspberry Pi icon in the upper left, click on Games and then Minecraft Pi.

Once Minecraft is open, click Start Game then join a preexisting world or Create New.  

Using the tab key to free your mouse from the Minecraft window, run the code and switch back to the Minecraft window.  “Hello, world!” should appear in the chat.

Going back to the code, type in the following

playerPos = mc.player.getPos()
mc.player.setPos(playerPos.x, playerPos.y + 50, playerPos.z)
mc.postToChat("Don’t look down!")
sleep(5)

The position of the players head is stored in the playerPos object.  The players new position is then set relative to the previous position (In Minecraft you stand on the XZ plane with the Y axis being vertical).

 

Running this code will in addition to the previous action of sending text to the chat but then teleport the player 50 blocks vertically of their current position.

 

It is ideal to type in code whenever possible as it helps with learning however this next section is rather large and copy-paste will make quick work.

playerTilePos = mc.player.getTilePos()
blockBelowPlayerType = mc.getBlock(playerTilePos.x, playerTilePos.y - 1, playerTilePos.z)
mc.setBlock(playerTilePos.x + 1, playerTilePos.y + 1, playerTilePos.z, blockBelowPlayerType)
mc.setBlock(playerTilePos.x, playerTilePos.y + 1, playerTilePos.z + 1, blockBelowPlayerType)
mc.setBlock(playerTilePos.x - 1, playerTilePos.y + 1, playerTilePos.z, blockBelowPlayerType)
mc.setBlock(playerTilePos.x, playerTilePos.y + 1, playerTilePos.z - 1, blockBelowPlayerType)
mc.postToChat("Trapped you")
sleep(5)

mc.setBlock(playerTilePos.x + 1, playerTilePos.y + 1, playerTilePos.z, block.AIR)
mc.postToChat("Be free!")
sleep(5)

Notice that a different method is called to identify the position of the tile the player is standing in.  The setBlock method allows a single block specified with an (X,Y,Z) coordinate and a block

After running the code try to look back and see if you can identify what each line is doing.

Now add the following to your code.

mc.setBlocks(playerTilePos.x - 25, playerTilePos.y - 1, playerTilePos.z - 25, playerTilePos.x + 25, playerTilePos.y - 1, playerTilePos.z + 25, block.DIAMOND_BLOCK)
mc.postToChat("Now that's a big diamond floor!")

Notice that the setBlocks method unlike the setBlock method can take a range of X, Y, and Z coordinates.

Running the code this time in addition to the previous actions will change the blocks in a 50 x 50 x 1 shape 1 block beneath the players feet.

Whats Next?

  • Modify the code, move the player in different directions.  
  • Add additional blocks to the trap.
  • Try changing DIAMOND_BLOCK to another block type, a list of the block types can be found in the API documentation, about halfway down the page
  • Inspect the API documentation to see how else you can interact with Minecraft using Python

Article and code adapted from source

image_pdfGenerate PDFimage_printPrint

RPi Node-Red: Neopixel LED Ring

Goal:

Use string injection nodes and a specific LED ring node to control a LED ring

What You Will Learn:

  • Basic Node-Red Programming

What You Need to Know:

Parts List:

12 pixel LED ring

3x male to female jumper wires

Getting Started:

Setting up the Hardware

Use jumper cables to attach the LED ring as in the image.
Attach the red wire to +5v, the black to ground, and the white data line to GPIO pin 18.

Setting up Node-Red

Start Node-Red and navigate to 127.0.0.1:1880  using the web browser.
Drag in the ‘rpi neopixels’ node; and double click on it to start editing its properties.



Set the LEDs field to the number of LED on the ring: 12. Set the Mode to ‘bar – Number of pixels’.  The other fields are all optional, but it might be nice to lower the Brightness, here I lowered it to 15 to lower eye damage. The LED ring can be painfully bright if you are indoors.

Next we drag in the ‘injection’ node, the LED ring node reads strings of text-based commands, and turns them into output on the ring.
We configure our injector like this; setting up Payload to be a string, and contents to be  ‘Blue’. Set the checkbox for Inject once after and set the timer to 1 seconds. Repeat can be set to ‘none’.

Connect the two nodes up like this, check your wiring from the start of the tutorial; and then you’re ready to hit Deploy.
If everything is setup correctly the LED ring should display blue within a few seconds.

The command ‘Purple’ sets the background color to purple on the LED ring.
When the LED ring is initialized all the LEDs are changed to the background color, this can also be set in the node preferences as one of the fields we ignored earlier.
If you read the ‘Node Help’ page for the LED ring node you can see further commands.

For example if we change the payload in the injection node to ‘5,Red’ and Deploy then the first 5 LED will be turned Red; the rest of the LED will remain at the background color we can set in the properties field.

Another possible command is a range of pixels, for example the command ‘3,7,Red’ will set pixels 3-7 Red.
The Color names the LED ring will accept can be found here on Wikipedia : https://en.wikipedia.org/wiki/Web_colors

CONTINUING
the next step is to connect this knowledge with other tutorials, see other tutorials to maybe connect the LED ring to a physical button, or use it in concert with other outputs like speakers.
More advanced logic can be used to turn the LED ring into a clock, or dial.

image_pdfGenerate PDFimage_printPrint

3D Printing: QIDI 3D Printer + Software Setup

Goal:

Setup your QIDI 3D printer from un-boxing to first print – you can use other 3d printers but will have to find their own instructions

What You Will Learn: 

  • How to assemble your printer
  • How to level the bed of your printer
  • How to slice 3D STL models into files the printer can print

Parts List:

Un-boxing and Assembly

Printer Bed Leveling

 

Since the Qidi printer is based on an open source design there are quite a few different printer control software packages you can use. The one we have settled on that seems to work best with the most useful features is the Flashforge Flashprint printer software. When using this software you need to select “flashforge

 

Steps:

  • Download Appropriate Software for your computer:
  • Choose Creator Pro as your printer: 
  • Load your STL file, if you need a 3D model to slice you can download your T3 logo here from Thingiverse!
  • Slice your 3D model by clicking on Print and selecting the appropriate settings
  • PLA is the recommended material – make sure you have PLA loaded into the printer also
  • Save your .x3g file to the 3D printer SD card you should have plugged into your laptop
  • Thats it! your file should be ready to print on the QIDI 3D printer!

 

image_pdfGenerate PDFimage_printPrint

RPi Node-Red: Camera

Goal:

Install the Raspberry Pi camera and take a picture using Node-Red

Parts List:

  • Pi Camera
  • Pi Camera Ribbon Cable

Getting Started:

Power off your Raspberry Pi and the follow the instructions on this page to install the camera.

Setting up Node-Red

Start Node-Red and navigate to 127.0.0.1:1880.  Into the flow area drag an “inject” node and a “camerapi takephoto” node.

Link them together.

Deploy the flow, then point the camera at something and press the inject button.  The camera will take a picture and then store it in /home/pi/Pictures by default.  Open the file explorer.

Click on the Pictures folder.

There your photo is!

Whats Next?

  • Try and trigger the camera node with a Raspberry Pi input node connected to a button or PIR sensor.
image_pdfGenerate PDFimage_printPrint

(Archive) RPi Node-Red: PIR(motion) Sensor

Goal:

Learn how to wire a passive infrared sensor and read it’s state in Node-Red.

What You Will Learn:

  • Basic Circuit Prototyping
  • Basic Node-Red Programming

What You Need To Know:

Parts List:

  • One PIR
  • Breadboard
  • Some Jumper Wires
  • One 100 Ohm Resistor

What is a PIR?

A passive infrared sensor or PIR is able to detect movement by measuring the change of infrared radiation.  This PIR comes in a 3 pin package, if you remove the diffusion cap you can see that the pins are labeled “VCC”, “OUT”, and “GND”.  VCC means “voltage at the common collector” and normally refers to a power rail within a circuit, this sensor requires 5 volts. OUT is the pin we will read information from.  GND is the ground connection.

Getting Started:

Setting up the Hardware

I encourage gently taking off the diffusion cap on the PIR to view the pins labels.  GND goes to ground, VCC goes to 5V, and OUT is connected to a 100 ohm resistor and then to GPIO20.  

Setting up Node-Red

Start Node-Red and navigate to 127.0.0.1:1880.  Drag a Raspberry Pi input node and a Debug node into the flow area.

Double click on the Raspberry Pi input node to open its configuration menu.  Set the Pin to GPIO20.  Name the node “PIR”.

The debug node can be left with it’s default settings, wire the button node to the debug node and deploy the flow.

If everything has been put together correctly, the state under the PIR node should change from a 0 to a 1 if movement has been detected and then back to 0 after a period of time, inspect the debug tab to view a log of these state transitions.  You may have noticed the two components under the PIR with a plus pattern on them. These are adjustable potentiometers, they control the sensitivity of the PIR and the duration of the activated state.

Whats Next?

image_pdfGenerate PDFimage_printPrint

RPi Node-Red: Push Button + LED or Buzzer

Goal:

Combine the use of Raspberry Pi input and output nodes in Node-Red to control an LED or buzzer with a push button.

What You Will Learn:

  • Basic Circuit Prototyping
  • Basic Node-Red Programming

What You Need to Know:

Parts List:

  • At Least 1 LED
  • At Least 1 Resistor
  • Piezoelectric Buzzer
  • Some Jumper Wires
  • Breadboard

Optional

  • Needle Nose Pliers

Getting Started:

Setting up the Hardware

This wiring diagram is simply the combination of the individual LED, buzzer, and push button circuits.  Make sure that the LED has a resistor on it. Wire a pin on the buzzer to GPIO16, wire the positive leg of the LED to GPIO12, and wire one of the pins on the button to GPIO25.  You can wire all the grounds to a rail and then to the GPIO GND or the connections can be made individually.

If it is difficult to put the components into the breadboard without the legs bending try and use needle nose pliers to help push the pins in.

Setting up Node-Red

Start Node-Red and navigate to 127.0.0.1:1880.  Drag one Raspberry Pi input node and two Raspberry Pi output nodes into the flow area.

Double click the Raspberry Pi input node to open its configuration menu.  Set the Pin to GPIO25.  Set Resistor? to pulldown.  I set the Name to “button”.

Double click one of the Raspberry Pi output nodes to open its configuration menu.  This will be the LED so set the Pin to GPIO12.  Leave Type set to Digital output, Initialise the pin state to low.  Name the node “LED”

Double click the other Raspberry Pi output node to open it’s configuration menu.  Set Pin to GPIO16.  Set Type to PWM output.  Set Frequency to 100.  Name the node “buzzer”.

Wire each output node to the single input node and deploy the flow.

If everything works properly activating the button should turn on the LED and activate the buzzer.  To stop either output node from activating just remove its connection to the button node and redeploy the flow.

Whats Next?

  • What other combinations can you make with the items in your kit?
image_pdfGenerate PDFimage_printPrint

(Archive) RPi Node-Red: Push Button

Goal:

Learn how to wire a push button and read it’s current state in Node-Red

What You Will Learn:

  • Basic Circuit Prototyping
  • Basic Node-Red Programming

What You Need to Know:

Optional

Parts List:

  • 1 Push Button
  • Breadboard
  • Some Male-Female Jumper Wires

Optional

  • Multi Meter
  • Needle Nose Pliers

What is a Push Button?

A push button is a momentarily activated button.  When the button mechanism is fully depressed an internal electrical connection is made and this newly made connection can be read as the activation of the button.

What is a Breadboard?

A breadboard is a prototyping platform that allows the easy creation of circuits without having to solder.  Each row of the breadboard is connected internally (not across the middle break). This mean that putting something into position 1a and 1b connects them electrically together while something plugged into position 1a and 2a are electrically isolated.  

The power rails on the left and right hand side of the breadboard are connected in a column and can be an easy way to access ground of power if you choose to route it there.  The color red and by extension the red column is often used for power while blue is often associated with ground and thus used for a ground connection.

Getting Started:

Setting up the Hardware

Take care when wiring the button to the GPIO, you want to connect the correct pins.  In it’s 4 pin package only some pins are isolated in the inactivated state.  A pair of pins that come out of the same side of the button are isolated as well as diagonal partners.  A multi meter on the diode setting can also be used to test if there is a connection between pins in an activate/inactivated state. Once you have identified the correct pair of pins attach one to 5V and the other to GPIO25.

Additionally it can be difficult to get the short legs of the push button to correctly make contact with the breadboard, I find that using needle nose pliers to straighten the legs of the push button and then inserting them 2 at a time to be a successful method.

Setting up Node-Red

Start Node-Red and navigate to 127.0.0.1:1880.  Drag a Raspberry Pi input node and a Debug node into the flow area.

Double click on the Raspberry Pi input node to open its configuration menu.  Set the Pin to GPIO25.  Set Resistor? to pulldown.  You can Name the node anything, I chose “button”.

The debug node can be left with it’s default settings, wire the button node to the debug node and deploy the flow.

If everything has been put together correctly you should see the number under the button node in the Node-Red flow change from a 0 to a 1 when the button is activated and from 1 to 0 when the button is deactivated.  You should also be able to see a record of the button activation in the debug tab of Node-Red.

Whats Next?

image_pdfGenerate PDFimage_printPrint

(Archive) RPi Node-Red: LED

Goal:

Turn a light emitting diode(LED) on and off using a button in Node-Red.

What You Will Learn: 

  • Basic circuit prototyping
  • Basic Node-Red programming

What You Need to Know:

  • Node-Red Basics

Optional

Parts List:

  • At Least 1 LED
  • At Least 1 resistor
  • Breadboard
  • At least 2 male-female jumper wires

What is a Breadboard?

A breadboard is a prototyping platform that allows the easy creation of circuits without having to solder.  Each row of the breadboard is connected internally (not across the middle break). This mean that putting something into position 1a and 1b connects them electrically together while something plugged into position 1a and 2a are electrically isolated.  

The power rails on the left and right hand side of the breadboard are connected in a column and can be an easy way to access ground of power if you choose to route it there.  The color red and by extension the red column is often used for power while blue is often associated with ground and thus used for a ground connection.

What is a Resistor?

A resistor is an electrical component that has a specific value of resistance measured in ohms.  Resistors are used to restrict the amount of current in a circuit or facilitate a drop in voltage.  Its value of resistance can be read in ohms using the colored bands on the body of the resistor.

What is an LED?

An LED is a light emitting diode.  Diode’s are a class of electronic components that are designed to only allow current to pass through them in one direction.  This means that LEDs are polar meaning they have an anode (positive) and a cathode (negative). Current must flow into the anode and the cathode must be attached to ground.  

There are several methods of identifying the anode and cathode:

  • Look at the lengths of the pins, If the LEDs’ pin have not been modified the longer pin is the anode and the shorter pin is the cathode
  • Look at the sides of the LED a portion of the case will be flat the pin on that flat side is the cathode 
  • Look inside of the bulb, each pin is connected to a flat piece of metal internally.  The pin that is attached to the larger piece is the cathode

An LED must have a current limiting resistor between it and ground or between it and power.  An unprotected LED will pull more and more current until it burns itself out. The value of the resistor will have an effect on the LEDs’ luminosity.  The higher the value of resistance the resistor has the less current will get to the LED and thus the dimmer the bulb will shine. The amount of current can be calculated in milliamps with Ohm’s Law, using the value in ohm’s for resistance

text{current} = frac{text{voltage}}{text{resistance}}

Getting Started:

Setting up the Hardware

If you are following the wiring diagram make sure to attach the cathode (straight leg in the diagram) of the LED to a resistor and then to GND (ground).  Attach the anode (leg with the kink) to GPIO #12.

Setting up Node-Red

Start Node-Red and navigate to 127.0.0.1:1880  using the web browser. Drag two inject nodes and a Raspberry Pi output node into the flow area

Double click on the Raspberry pi output node to open its configuration menu.  Set the Pin to the same pin you physically connected the LED to. If you are following the wiring diagram this is GPIO12.  Leave the Type as Digital Output.  We can also Name the node, since I used a green LED I named it “Green led”, this follows a good programming practice of accurately and succinctly naming variables.

Double click one of the inject nodes.  Use the drop down menu to change the Payload data type number, type a “1” in the text box.  Name the inject node “on”.

Double click the unmodified inject node.  Use the drop down menu to change the Payload data type to number, except type a “0” in the text box.  Name this node “off”.

1 and 0 correspond for to values of a binary digit(bit) true and false, high and low, on and off respectively.  These are called boolean values and are a fundamental data type in Computer Science.

Connect the inject nodes to the output node and then deploy the flow.

The green square under the Green LED node tells us what state the LED is in, 1 being on and 0 being off.  Injecting a different value will change the state from off to on or from on to off.

Whats Next?

image_pdfGenerate PDFimage_printPrint

RPi Node Red + Camera

image_pdfGenerate PDFimage_printPrint