Creators – Week 11

This week we completed our ship from the previous week by adding some materials. Materials are what provides colour to models.

Out model, by default, contains a single material slot. This default material is a grey material and because there’s a single slot, it’s applied to all faces.

To start colouring our model we went to the material properties panel on the right-hand-side of the screen. It has a red circular icon as seen at (1) below.

We removed the default material slot by using the – key at (2) above then then added two new materials, called Ship and Ship_Detail by pressing + at (2) to make two new material slots and using the “New” button at (3) when those empty slots where selected to actually make a new material.

The default material component has a lot of inputs, but we can ignore most of them for now. The most important ones are:

  1. Base Colour: This is the main colour of the material
  2. Metallic: How much like a metal the material is. Although a slider, its normally to be either zero (not a metal) or 1 (a metal) rather than anything in-between.
  3. Roughness: How smooth or rough the material is. Will greatly impact how light reflects off the object. Metallic materials with very low roughness look mirror-like.

We set Ship and Ship_Detail with contrasting colours, metallic finish and low roughness.

Environment

We are going to create loads of environment sections that snap together. The follow the basic pattern show above. A flat area 90x100m in size, with a vertical edge 4m high and a 20m flat area beyond that. We can add any embellishments to the raised flat area on the sides, so long as they’re not too high on the side facing the camera. We don’t want to obscure the ship.

Like the ship, we created two contrasting materials for the environment, one dark as a base and one bright as a contrast colour for details.

Getting the Model

The Blender model for this week can be downloaded from our Teams site here.

Medtronic Foundation – Laptop Donation

Medtronic Logo

We are very grateful to the Medtronic Foundation, through Medtronic employee and mentor Declan Fox, for the donation of several laptops to CoderDojo Athenry. Our loaner laptop program helps those who cannot otherwise afford a laptop to attend CoderDojo Athenry. Keeping CoderDojo Athenry free to attend and as inclusive as possible is always one of our key aims.

The Medtronic Foundation partners to improve health for underserved populations, as well as supports communities where Medtronic employees live and give. They empower Medtronic employees to positively impact local communities by leveraging their skills, time and resources. If you’d like to read more about their work you can find their webpage here.

Bodgers – Distance Sensors

This week we will be using the HC-SR04 Ultrasonic Distance Sensor

Wire up the sensor as shown below

Here is the code we will need for the sensor.

#From www.tomshardware.com/how-to/raspberry-pi-pico-ultrasonic-sensor
from machine import Pin
import utime

trigger = Pin(17, Pin.OUT)
echo = Pin(16, Pin.IN, Pin.PULL_DOWN)

def ultra():
   trigger.low()
   utime.sleep_us(2)
   trigger.high()
   utime.sleep_us(5)
   trigger.low()
   while echo.value() == 0:
       signaloff = utime.ticks_us()
   while echo.value() == 1:
       signalon = utime.ticks_us()
   timepassed = signalon - signaloff
   distance = (timepassed * 0.0343) / 2
   print("The distance from object is ",distance,"cm")

while True:
   ultra()
   utime.sleep(1)

Once this is working you can move on to this week’s challenge. Combine this with the LED code from the last session so that the LED flashes when the distance measured by the sensor is less than 30CM. Here is the LED code:

from machine import Pin
from time import sleep

led = Pin(15, Pin.OUT)

def flash():
    led.value(1)
    sleep(0.5)
    led.value(0)
    sleep(0.5)
    
while True:
    flash()