Bodgers – Getting started with Python

Hi Everyone

It was great to get back again with a full year to look forward to and it was also great to see so many people interested in getting involved with CoderDojo Athenry.

In the Bodgers group we got off to a great start, we installed the Mu Python editor, and we wrote our first few programs.

Bodgers

The Mu editor can be downloaded from here: https://codewith.mu/.

You can find our code from last Saturday on the last couple of slides from this week’s notes here: Bodgers Day 1

We also decided we’re going to do a few small projects between now and Halloween and then start on a bigger project after that.

Next week we are going to make a Space Invaders style game, you can find some images for it here: https://www.dropbox.com/home/Bodgers/Space%20invader/Images.

Looking forward to seeing you all next week.

Declan

Bodgers – A Look Back At 2020/2021

Hello everyone,

I would like to thank all the Bodgers who joined me this year. I really enjoyed the sessions and I’m really grateful to you all for your attention, patience and your willingness to help me and each other out.

It’s a pity we couldn’t get together for even one session but hopefully when CoderDojo Athenry gets back to in person sessions I can meet you all then. I would also like to invite you all to our first post-COVID pizza party (hopefully before Christmas).

I have put together a video of the games we made this year.

Special thanks to everyone who created levels for our Red Runner game. You can find a copy of the code and images for this game on Dropbox here: https://www.dropbox.com/sh/sj6hil242d3fxmk/AAAHPnEVjw5IGWqs_G3eTXkDa?dl=0.

Thanks also to Kevin who helped us get up and running.

Enjoy the summer and hopefully I’ll see you in the autumn.

Declan

Bodgers –Magic Ball

This week in the Bodgers group we revisited Pygame Zero and worked on a fortune telling game based on a Magic 8 ball.

I gave the group some artwork I prepared in the Paint.NET graphics editor and we wrote some code to animate them.

I’ve added the code and images to Dropbox here.

See you all on Saturday for Belts and Pizza, don’t forget to bring drinks.

Declan, Dave and Alaidh.

Bodgers – Texts & Emails

This week we looked at sending texts and emails from our python scripts.

To send text messages you will need to set up an account on Twilio which is a platform that allows coders to make and receive phone calls, send and receive text messages from their programmes. You then install the Twilio python library which will allow us to send texts from our script using code like this.


# Download the helper library from https://www.twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/console
# DANGER! This is insecure. See http://twil.io/secure
account_sid = 'your account_sid'
auth_token = 'your auth_token'
client = Client(account_sid, auth_token)

message = client.messages \
                .create(
                     body="Hello Bodgers",
                     from_='+440123456789',
                     to='+353123456789'
                 )

print(message.sid)

To send an email we use smtplib which is an email library that’s built into python and which works well with Gmail. We need to change our Gmail setting to allow insecure apps and then we can use the code below to send our message.


import smtplib

server = smtplib.SMTP('smtp.gmail.com', 485)
server.starttls()
server.login("my.email@email.com", "myPassword")

msg = "Hello World"
server.sendmail("my.email@email.com", "some.email@email.com", msg)
server.quit()

See you all on Saturday

Declan, Dave and Alaidh

Bodgers – Pi Camera & OpenCV

This week in the Bodgers group we looked at the Pi Camera Module which is a high quality image sensor add-on board for the Raspberry Pi. You can capture images  from the command line with:

 raspistill -o cam.jpg 

This will take a jpeg picture called cam which will be saved in your home folder.

You can take a picture from your Python script with:


from time import sleep
from picamera import PiCamera

camera = PiCamera()
camera.resolution = (1024, 768)
camera.start_preview()
# Camera warm-up time
sleep(2)
camera.capture('foo.jpg')

This will save a picture called foo in the folder you ran your script from.

OpenCV (Open source computer vision) is a library of programming functions mainly aimed at real-time computer vision. We tried a couple of scripts out, one from the Hackers group, thanks Kevin, that detects colours and another one that detects shapes, we will be looking at this much more in the next few sessions but next Saturday we will look at using an Arduino and a Raspberry Pi together.

See you all then.

Declan, Dave and Alaidh

Bodgers – FreeCAD and Fritzing

Hello again everyone

This week we continued working on our Astro Pi entries and we also looked at FreeCAD and Fritzing which are tools that will help us with building our projects.

fritzing_freecad

FreeCAD, available for download from here, is used for 3D modelling and allows us design very complicated things from simple 3D shapes such as cubes and cylinders. Here are a couple of quick videos to get you started.

Then we looked at Fritzing, download from here, an application for drawing very easy to understand circuits, here’s how to draw a simple circuit using it.

 

Dave will be leading next Saturday’s session and I will see you again on the ninth of Feb.

Declan, Dave and Alaidh.

Bodgers – Motors and Robots

This week in the Bodgers group we looked at controlling motors and robots withe the Raspberry Pi.

You can find the code for this weeks session here and my notes are here motors and robots

We also talked about ideas for the projects we will be working on for the rest of the year. Tomorrow we will continue to look at robots and we will also do some brain-storming for our projects.

See you then.

Declan, Dave and Alaidh

Bodgers – Traffic Light with Buzzer

This week we continued working with GPIO Zero, at the end of last week’s session we had started working on a simple LED traffic light, we finished of that this week and we added a buzzer to it.

circuit2

I had hoped to work on the HC-SR04 distance sensor but there seems to be an issue with them on the Raspberry Pi at the Moment.

Here is a video that demonstrates what we covered on Saturday.

See you all next Saturday (08-Dec) for our Christmas party.

Declan, Dave and Alaidh

 

Bodgers – Introducing Gpio Zero

Hi again everyone.

This week we started looking at physical computing and the Raspberry Pi. This involves attaching various components such as sensors, motors or controllers to the GPIO pins on our Pi. This week we connected a LED and two buttons, and we used the GPIO Zero module for Python to control them. I’ve made a video, it’s a little bit long, that covers everything from Saturday’s session.

 

At the end of the session the group started working on a traffic light idea and we will combine this with HC-SR04 ultrasonic distance sensor next week to create a measuring device.

I don’t have any slides this week as we worked directly from the GPIO Zero Documentation available at https://gpiozero.readthedocs.io. This is also available on Dropbox, along with this week’s code and a sheet that contains a drawing of our circuit and drawing of the GPIO pin layout, here: https://www.dropbox.com/sh/k26mbrfmdvq9tro/AAB5jfjkIlBqLhfnUAVVUvtJa?dl=0.

See you all next Saturday.

Declan, Dave and Alaidh.

Bodgers – Finishing Our Game

Hi again everyone.

This week we put the final touches to our game.

uwin

We added some code to increase the speed of the alien sprite as the score increased to make the game a little more difficult.

We then added some code to control what happens when the game is over.

You can find our code on Dropbox here: https://www.dropbox.com/sh/ccfaycpa1zluh8l/AAAA4dQH8EPNJicsQj7RwGgsa?dl=0

Next week we will do a quick recap of this game and then we will start looking at hardware on the Raspberry Pi.

See you all then.

Declan, Dave and Alaidh.