CoderDojo Athenry Information Session, Sept 2019

Thank you to everyone who came along for our information session yesterday Saturday 14-Sep-2019.info_session

Michael introduced us to the CoderDojo movement and then talked to us about CoderDojo Athenry and what we have planned for 2018/2019. Michael’s presentation is here:CoderDojoAthenry-InfoSession-2019-Sept .

Julie then spoke about our loaner laptops where we provide laptops for people who don’t have their own. Speak to Julie or any of the mentors (we’ll be wearing blue t-shirts) for more information.

Martha then spoke about Health & Safety and our shop, where we sell tea/coffee with biscuits for €2.00 or €1.50 if you bring your own cup, with all profits going towards equipment etc. for our CoderDojo. The H & S and Coffee Shop slides are here: HS-and-Coffee .

info_session1

This year, we have 4 different rooms with different topics in them, for different levels of experience and age.

Explorers- led by Martha for Beginners from around age seven. They use the Scratch programmimg language to build games, quizes and animations. Here are Martha’s slides: CDA-Explorers-S8-Information-Session .

Advancers- led by Oliver is for kids who have already been through Explorers. They tackle more complicated programming concepts, during the year the Avancers group will investigate various topics like gravity, music and even what happens when water boils using Scratch.

Modellers- led by Kieran is for older kids who have been through Explorers and Advancers. The Modellers group will concentrate on making 3D game resources using apps like Blender and Gimp. Here are Kieran’s slides: CoderDojoAthenry-Modellers-KickOff-Sept2019.

Hackers- led by Michael for older teenagers who have been through Creators and Bodgers. The Hackers group themselves usually decide what topics they will cover with many of them working on their own projects. Here are Michael’s slides: Hackers-Intro-Slides.

Kids are free to move between rooms until they find a topic that suits them.

To find our schedule for the 2019/2020 sessions click on the schedule button at the top of this page.

If you have any questions or if you need any help, please talk to me or any of the mentors.

See you all next Saturday.

Declan and the CoderDojo Mentors

CoderDojo Athenry Returns on 14 September 2019!

return

CoderDojo Athenry is starting back with an information session on 14 September 2019 in Clarin College Athenry (“the Tech”) at 12:00 noon. All new and existing members are welcome to come along to find out what we have planned for this season.

Regular weekly sessions will start the following week, 21 September 2019, 12-2pm in the same venue.

New members are always welcome. If you are aged between 7 and 17, just come along on the first day and fill out a registration form. Young people aged 12 and under have to be accompanied by a parent/guardian for the whole session.

And don’t forget, CoderDojo Athenry is run by volunteers and is completely free for participants — no membership fees, no weekly contributions. You should bring a laptop if you have one, but we have some loaner laptops if you don’t. There is more information on our About page.

We hope you can join us. You are welcome to invite your friends along too!

Congratulations to all our ninjas who received belts in Summer 2019!

On 2 May 2019, at our final CoderDojo Athenry session of the 2018-19 year, we awarded a total of 75 belts to our ninjas for their great individual achievements in acquiring and demonstrating coding and computing skills. And then we had a party with pizza!

Here is a link to our presentation from the day: CoderDojo Athenry Belts Day 2019

We are very grateful to Clarin College Athenry and the principal, Ciaran Folan, for their enabling CoderDojo Athenry by making the school and its wifi available to us.

We are also very grateful for the sponsorship and support we have received this year:

  • Galway Roscommon Education and Training Board, who provide us with an annual Youth Club Grant
  • Medtronic, employer of our mentor Declan Fox, who provide us with a grant to match Declan’s excellent volunteering
  • HP Enterprise, employer of our mentor Mark Davis, who provide loaner laptops that we make great use of
  • Boston Scientific, employer of our mentor Kevin Madden, who provide us with 3D printers.

 

Thanks also to everyone who supported us by buying tea or coffee!

Because of these supports, no child or parent/guardian ever has to pay to participate in CoderDojo Athenry.

And of course we must thank our mentors, who volunteer their time and expertise entirely without charge week after week, to make CoderDojo Athenry the success that it is.

Here is the full list of belts we awarded:

  • Explorers:    34
  • Advancers:  25
  • Bodgers:     8
  • Hackers:      5
  • Creators:     14
  • Black Belt:   2

Special mention must go to Eoghan McGuinness and Ruaidhri Madden, who received their black belt awards. Both have been in CoderDojo Athenry for several years, working their way up through the groups, and this year started Mentoring. Well done, Eoghan and Ruaidhri!

CoderDojo Athenry is now closed for the summer. See you all in September!

Creators: General Zod 3D!

This week in Creators we explored 3D and build an animation or two using it.  The final one was a “General Zod” simulation where we recreated a scene from a classic movie

Check it out here!

general-zod

This scene used the following elements:

  1. 3D Canvas! Our canvas was set up to use WEBGL – enabling this means you can use the 3D capabilities and shapes of p5
  2. Shapes – just the two shapes here:
    1. a “Box” which is your floating “prison”
    2. an “ellipsoid” which represents Krypton
  3. Lights!
    1. We looked at the different types of lights in WebGL (ambientLights, pointLights and directionLights) and for this scene I went with a few directionLights to light things from various directions
  4. Action!
    1. Positioning and moving the shapes is performed by transforms.  We moved the rather large planet to the bottom with translate and made the prison rotate and vanish off into space with a few rotate statements.
    2. Note that with 3D stuff, we have the use of a rotateX, rotateY, rotateZ since we can rotate in lots of ways!  I also added a rotation to Krypton above to make it more realistic.
  5. Texture!
    1. Krypton: We looked at adding textures which is an image that you paste onto the object.  The sphere above is textures with an image of Mars I found – not sure what Krypton is like I but I picture it as kind of orang-ish.
    2. Prison: For texturing the prison we did the same thing, but with a difference!  It still is using an image as the texture but it’s using the p5.dom library to control the web camera and take pictures from that every frame.  This allowed us to place ourselves “live” in the scene.

It is pretty amazing the animations and effects you can create with very little code using the p5 webGL library.  Happy coding!

Congratulations to our Ninjas at Coolest Projects 2019

Congratulations to everybody from CoderDojo Athenry who participated in the CoderDojo Coolest Projects International in the RDS Dublin on 04 May 2019.

We had three projects which all sparked a lot of interest with the public at the event. Adam presented his game “The MegaMaker”, David and Michael presented “FidoFinder” and “Go With The Flow” was presented by Mark.

 

Special congratulations to Adam who was runner up in the Games category and the Go With The Flow team represented by Mark who were runners up in the Hardware category.

 

Creators: Drumtown!

Today in Creators we played a bit more with sound and built a type of musical instrument using Javascript.  The project was called “Drum Town” because it was based on the idea of a music mad building and when you wake up one of the resident’s by clicking their window, they would play a particular sound every time some traffic cruised past.  Each floor consists of people with the same instrument.  What else would they do?

Play the finished Project by clicking here! – Make sure to TURN UP THE SOUND!!

drumtown

How did we build it?

The awesome thing at this stage is that the group has become so competent at javascript that as soon as we had the idea, some people put their heads down and started building without a whole lot of direction!!  I won’t go into the ins and outs here, but the code is up on our repository and you can go through it!

Interesting bits!

Some of the interesting bits of the project are:

  1. Classes:
    As usual we needed a few classes – this time we used classes for the Car and the Window.  The basic idea was to have a car moving at a constant speed left to right and to have windows that play a sound whenever the car goes past.
  2. Unicode Sprite Characters!
    We learned that now text is getting more and more graphical – we can see it on our phones with emoticons.  There are a large amount of emoticons in standard fonts and if you enable the windows keyboard (right-click taskbar and choose “Show Keyboard” you get on onscreen keyboard that can type all sorts of characters – we used these for our cars:  and could write crazy looking code like:  this.carList= [🚗, 🚚, 🚛, 🚕, 🚜]; .  This will make it REALLY easy for us to write games with nice looking costumes without messing with images.
  3. Sounds:
    I handed out some sounds for us but you can put whatever sounds you like in your own version.  I got my sounds from this website here which has TONS of free instrument sounds!  We named the sounds 0-6.wav to make it easier to use loops to reference them.

That’s it!  Take a read through the code, I finished it off a little before pushing (mainly added a title).  It would be great to make your own version with a different them and a different set of sounds perhaps.  Also – maybe this can give you ideas for other types of musical instrument that you can create, perhaps with a completely different model. Have fun with the emoticons too 📯🎷🎺🎸🎻!

Creators: Autonomous Agents!

This week in Creators we did a very fun project – we learned how to simulate creatures with a kind of basic artificial intelligence and their own hopes, dreams and aspirations!  We made an app where a bunch of creatures desired to spell the word “Creators” and were also scared of the mouse.

Click on the image below to play with our completed animation.

creature-steering

All the code is on the creators github as usual! Pretty cool eh?  How did we get it working?

The evolution of Consciousness
At the start we chatted about an interesting channel on youtube called Kurzgesagt which contains short videos on all sorts of interesting topics.  A recent video I watched discussed the notion of consciousness and how it might have evolved and it inspired the project.  Though a lot is speculation about this topic, the video made a reasonable argument that consciousness evolved as a survival tool to allow simple creatures to seek energy (food) and flee from creatures that wanted to eat them.  Watch the video, it’s very good!

Though we aren’t quite at the stage where we are ready to code up conscious beings – it was interesting to think about how we might add needs and desires to a character, so that’s what we looked at!

Reynold’s Steering Behaviours for Autonomous Characters
Having decided that we wanted some creatures that moved to the beat of their own drum, we next needed to figure out how to implement it.  There are LOTS of pretty complicated strategies for simulating intelligence, but we looked at a brilliant research paper published in 1999 by a playstation programmer called Craig Reynolds called Steering Behaviours for Autonomous characters – read the full paper here.  In this paper, Reynolds describes a simple but fantastic way to model “autonomous” characters using forces.

steering2

An “Autonomous” character is one that controls or powers itself – i.e. there is no remote control here! There is a lot in Reynolds paper but the basic idea is to think of some “behaviours” that a creature might exhibit – these could be:

  • Flee: perhaps the creature might want to escape from someone?
  • Seek: perhaps the creature might want to get somewhere really quickly?
  • Arrive: perhaps a creature might want to get somewhere and stay there (i.e. slow down to “arrive” there.
  • Be close to other creatures: perhaps a creature might want to be close to creatures like them
  • etc – basically anything you can think of nearly!

In Reynold’s paper, creatures generally have a limited vision, and can have more than one behaviour happening at once – i.e. I really want to get food, but want to avoid the predator in the way.

The simple but powerful that Reynolds came up with is the idea of using forces to describe these behaviours and letting newton sort it out.  To model a Reynolds behaviour, you:

  1. Determine your DESIRED velocity for this behaviour – this is a force describing how badly you want to escape the predator, or pursue the target, or avoid the obstacle, etc
  2. You STEERING force vector is worked out as:

steering = desired – velocity

With this simple looking formula, and behaviour rules you combine, you can create some great behaviours that can seem to have realistic looking intelligence behind them.

The Code
Because Reynolds uses force, we had an object which could be a good starting point developed way back in Week 8 – our fun with forces model was a perfect starting point since we already had a “Mover” object that had an applyForce function to allow you to add a force to it.

seek-fleeOur movers “seek” home and “flee” the mouse

All we needed to do was to add some “personality” to our Mover so that it decided itself where it wanted to move to.  These are called “behaviours” in Reynolds brilliant paper.  We decided that our first Mover would have a “timid, homebird” personality and it would have two desires: to get home (some location that is dear to it!), and to stay away from the mouse.  We decided that when it is “afraid” of the mouse we should add something visual to let us know it was afraid – we coloured it red.

The first and easiest code to add was the code to make the Mover want to go home:

 goHome(){
    // i want to go home
    let desired = p5.Vector.sub(this.home, this.position);
    desired = desired.limit(this.maxSpeed);
    let steering = p5.Vector.sub(desired, this.velocity);
    this.applyForce(steering);
}
This is a good example of the process – first we create a Vector that describes where we want to go (home – location), next we limit it to the maximum speed of the Mover.  Next we use the magic formula of Steering = Desired – Velocity to find what the steering force should be.  (This looked okay for us, but in Reynold’s paper he recommended a maximum steering force so it doesn’t steer too quickly – good idea but we didn’t bother with it!).  We called this “goHome” but Reynolds calls this the “Seek” behaviour.
 flee(){
     // i am scared of the mouse
     let mousePosition = createVector(mouseX, mouseY);
     let desired = p5.Vector.sub(this.position, mousePosition);
     let dist = desired.mag();
     if(dist < 100){
         desired = desired.limit(this.maxSpeed);
         let steering = p5.Vector.sub(desired, this.velocity);
         this.applyForce(steering.mult(10));
         this.isAfraid=true;
     } else {
         this.isAfraid = false;
     }
}
The next steering behaviour was fear of the mouse.  We added this as per the above “flee” method.  We imagined that our little creatures can see the mouse when it’s 100 pixels away, and if it is, then it’s afraid and a very strong “flee” force is present.  In the show method we decided to show the fear by turning it red (we should have drawn e.g. a scared face or something).
Finally, we add a function which calls the behaviours in turn:
applyBehaviours(){
    this.flee();
    this.goHome();
}
In each draw loop instance, we call the applyBehaviours, just like we call the “move” method and the “show” one.
That’s it!  That’s all it took to give our creatures the desired behaviours!
Drawing a message:
The code to draw a message came from a hidden feature of the font class in p5 – the ability to get points from text with textToPoints.  This allowed us to get a bunch of points to set as home which spelled a message.   Depending on your computer, it could run a little slow so you might want to just add every 2nd points (takes a while to paint on my phone, but looks quite good on my laptop!).
function preload(){
    font = loadFont("fonts/AvenirNextLTW01-Medium.ttf");
}

function setup() {
    createCanvas(innerWidth, innerHeight);
    textFont(font);
    points = font.textToPoints("Creators", 100, height/2, 300);
    
    for(let i=0; i< points.length; i++){
        let startPosition=createVector(points[i].x, points[i].y);
        movers.push(new Mover(random(10,30), startPosition));
    }
}

Creators: Shootah Part 2 – Sound and Bullets

This week we carried on our “Shootah” space shooting game  by adding some bullets with an appropriate sound effect.  This brings the game to the stage shown below:

Not very snazzy but it’s starting to show some promise!

As with last week, this will only run if served up from a web server, we had a few ninjas in that missed last week and had to install node.js and local-web-server application.

Bullets!

Our Bullets were a pretty simple object that just moves up constantly – this has the following code:

class Bullet {
    constructor(x, y){
        this.x = x;
        this.y = y;        
        this.speed = 10;
    }

    move(){
        this.y = this.y - this.speed;
    }

    show(){
        push();
        fill("yellow");
        ellipse(this.x, this.y, 10, 10);
        pop();
    }
}

We created an array of bullets and added a new one to the array each time the up arrow is pressed.  In addition, we played a “firing” sound which really adds to the feeling:

function preload(){
   playerImage = loadImage("images/spaceship.png");
   bulletSound = loadSound("sound/laser.mp3");
}

function draw() {
  // .... skipping a few lines
  for(let i=0; i< bullets.length; i++){
     bullets[i].move();
     bullets[i].show();
  }
  // .... skipping a few lines
}

function keyPressed(){
   if(keyCode==UP_ARROW){
   bullets.push(new Bullet(player.x, player.y));
   bulletSound.play();
 }
}

 

The sound was done very similarly to the image – we created a folder (sound) and added a sound file we found on the internet to the folder.  In the preload function we loaded the sound from the file into a variable (“bulletSound”).  In the keyPressed function, we check if the pressed key is UP ARROW and if so, we play the sound and add a new bullet to the list.. voila!

Problems to work on!

A great start but a lot left to be sorted with this game!  Here are some of the items:

  • The bullets array grows forever – this really starts to slow down the game as we keep playing it.  We need to add some code to remove a bullet from the array when it is gone off the screen.
  • The player has no edge detection – we need some way to keep it onscreen.
  • We need some enemies!!
  • We need to get the bullets to check when they are hitting the enemies!
  • We need to keep and display a score
  • We need a way to die.. perhaps the enemies can drop bombs?
  • Other ideas:
    • Maybe a background tune in a loop?
    • Maybe a scrolling starfield in the background?
    • Maybe multiple levels?
    • Maybe different types of enemies?
    • Maybe a shield?
    • Perhaps some different weapons or weapons you can pick up?

We have gotten this far so we might as well push forward and make this a fully working game so we’ll get some of the above sorted next week!  The code is as usual up on our github.  https://github.com/coderdojoathenry/creators2018

 

 

 

Hackers – Controlling Motors with an Arduino and H-Bridge

Previously in Hackers we have studied how transistors work, and made a transistor-based circuit to control a motor from an Arduino: Hackers – a Joule Thief and Controlling Motors.

When you write to a pin on the Arduino, it outputs a voltage. However, you can’t use this directly to drive an electric motor, because they require too much current, and it would damage the Arduino. The solution is to use a 6V battery as an external power supply, and connect it to the motor via a transistor circuit. When you apply a signal with small current to the middle leg of the transistor, a much larger current can flow from the battery to the motor.

While this works, a more elaborate circuit is needed if you want to be able to control two motors, and make them go backwards and forwards. This circuit is called a Dual H-Bridge. The Wikipedia page has technical details: https://en.wikipedia.org/wiki/H_bridge

We are using a pre-built integrated circuit for our H-Bridge, as they are low-cost, small, and work well. Here is the one we are using:

h-bridge

It has several connectors:

  • [+] and [-] are where the external battery is connected
  • [IN1] and [IN2] control Motor A (details below)
  • [IN3] and [IN4] control Motor B
  • [Motor A] and [Motor B] each have two pins that are connected directly to motors

To control Motor A, connect [IN1] and [IN2] to two pins of the Arduino, such as 6 and 7:

  • [IN1] HIGH and [IN2] LOW: Motor A goes forward full speed
  • [IN1] LOW and [IN2] HIGH: Motor A goes backward full speed
  • Both LOW: Motor A does not turn (no power, it coasts)
  • Both HIGH: Motor A does not turn (is braked)
  • To control speed, use a value for the pins connected to [IN1] or [IN2] in the range 0-255 (0=LOW, 255=HIGH)

Here is Arduino code to control a motor with a H-Bridge, written by Luke, one of our Hackers:

// Luke Madden, CoderDojo Athenry
// Control motors using a H Bridge

// The H bridge has 4 input pins: in1-in4
#define in1 6
#define in2 7

int fast = 100;// range 1-255
int slow = 50;// slower speed
int hyperspeed = 255;// hits the hyperdrive

void setup() {
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  drive();
}

 void drive() {
  // Test the functions
  Serial.println("move forward");
  forward();
  delay(2000);

  Serial.println("hit the hyperdrive");
  hyperdrive();
  delay(2000);

  Serial.println("go backwards");
  backwards();
  delay(2000);
}

void forward() {
  //makes motor go forwards
  analogWrite(in1, fast);
  analogWrite(in2, 0);
}

void hyperdrive() {
  //hits the hyperdrive
  analogWrite(in1, hyperspeed);
  analogWrite(in2, 0);
}

void backwards() {
  //makes motor go backwards
  analogWrite(in1, 0);
  analogWrite(in2, slow);
}

void stopping(){
  //makes it stop
  analogWrite(in1, 0);
  analogWrite(in2, 0);
}

Hackers – Hide and Seek

We welcomed back Hackers Group members Luke and Sean, who had projects at the Young Scientists Exhibition last week.  Details of their projects are in another post: Congratulations to our members who presented at the BT Young Scientists 2019!

This week we divided the group into two teams to work on our hide-and-seek robots:  One team to build the hider robot, the other to build the seeker robot.

The two robots can use many of the same parts, but the control systems will be different.  The hider robot will be operated by a person with an RC transmitter.  The seeker robot will control itself.

Team Hider started resurrecting a radio-controlled robot that we built last year.  The robot was involved in a battle-bots battle at the end of the year, so it is in pretty poor shape.
Teem Seeker worked on a colour tracking system.  We took the code that we developed on a laptop before Christmas and tried it on two Raspberry Pis.  We found that the original model Raspberry Pi wasn’t fast enough to do the job we needed.  It took 6 seconds to acquire an image from a webcam.  We tried a Model 3 B instead.  This was fast enough for our needs.  We then started work on tuning the colour detection.  There’s some more experimentation to be done to find the best colour range to work with.