Hackers – Remote Controls for Our Bots!

Remotecontrols

In the Hackers group this week, we took a large step forward in our Project SABRE (Small Autonomous Battling Robotic Entities), when we started working with remote controllers for our robots.

Components

From what the group has read, it looks like the most widely-used controllers are Spektrum-compatible DSMX or DSM2 ones. Therefore, we bought 3x Lemon RX DSMX/DSM2 receivers and one MLP4DSM Blade transmitter (as shown in the photo).

Connecting to the Arduino

Pins on the receiver are simply connected to digital pins on the Arduino.

To program the Arduino to read the receiver, this code has been cross-referenced from other forums: https://www.sparkfun.com/tutorials/348

According to the comments, while this works, you should use interrupt-driven code.

This StackExchange post has a good list of possible references:

https://robotics.stackexchange.com/questions/1207/read-multiple-channels-of-rx-tx-with-arduino

There was a lot of excitement when people were able move the joystick on the transmitter and have it change the value being printed out in the Arduino console!

Bodgers – Basic Electronics

Hello again Everyone.

I was away this weekend so Dave looked after the group.

He covered some basic electronics theory such as Ohms Law, how we use resistors in our circuits to protect other components and how to wire up an LED. He also helped the group build a simple traffic light circuit controlled by an Arduino which they then programmed.

The Raspberry Pi Foundation have announced that they are not running the Pioneers Challenge this year and are instead concentrating on the Coolest Projects. This means that Coolest Projects is now open to Code Club and Raspberry Jam members. There will be a UK Coolest Projects in April in London and Coolest Projects in Dublin will now be called Coolest Projects International. See more info here.

We have two sessions before the mid-term break so we will concentrate on coming up with ideas for our next projects and how we might implement these ideas and that will leave us a couple of weeks to get components etc. organized.

See you all next week.

Declan, Dave and Alaidh.

 

Hackers – Building Battling Bots for Project SABRE!

projectplan

In recent weeks in the Hackers group, we have been refining our plans for Project SABRE (Small Autonomous Battling Robotic Entities).

Our mission for Project SABRE is to build “battlebots” that include some autonomous features. While there are many kits available for purchase, our two teams of hackers are designing and building their bots from scratch, identifying and sourcing all components ourselves, 3D printing bodies of their own designs, and programming everything themselves. Even the mentors are hands-off, helping mainly with project planning and purchasing, but not designing or making.

The main components required are:

  • 2 or 4 motors with wheels or tracks
  • Battery packs and chargers (salvaged from old toys)
  • An Arduino
  • A motor driver board or chip — these work just like the transistor circuit that we experimented with previously, but can control up to 4 motors and drive each one forwards or backwards: https://coderdojoathenry.org/2017/11/22/hackers-a-joule-thief-and-controlling-motors/
  • A servo motor if needed for a flipper arm
  • A 2.4 GHz radio transmitter and receiver

Stay tuned as the work continues in the coming weeks!

 

Creators: Spirograph

This week in the Creators group we looked at emulating the classic toy, the Spirograph.

spirograph3

The Spirograph consists of geared plastic discs. One disc is fixed in place over a sheet of paper and the other, with a pencil tracing the path, is allowed to spin around it. The result is a complex and beautiful design on the paper.

Screen Shot 2018-01-30 at 17.04.14

This diagram should help explain in conjunction with the photo. The centre of the black disc spins around the centre of the red disc, which itself doesn’t move. So the centre of the black disc rotates around in a circle. Pretty simple?

Now, the pencil itself rotates around the centre of the black disc. Shouldn’t that make a circle too? Well it would if the black disc wasn’t moving. Thankfully though, it is and that’s what makes this interesting.

Finding the Location of the “Pencil”

So how do we find the location of the pencil? Let’s look at our diagram again, but with things re-labeled a bit:

Screen Shot 2018-01-30 at 17.33.58

  • Centre: Formerly “centre of red disc”. It’s the fixed centre of our spirograph
  • Centre2: Formerly “centre of black disk”
  • Point: The point on our curve. This is where the pencil would be in a physical spirograph.
  • Radius0: Distance from Centre to Centre2
  • Radius1:Distance from Centre2 to Point
  • Angle0: The current angle of the line between Centre and Centre2
  • Speed0: The amount that angle0 increases every time we draw
  • Angle1: The current angle of the line between Centre2 and Point
  • Speed1: The amount that angle1 increases each time we draw

So at any time the location of our point is:

Point = Centre + [Centre2 relative to Centre] + [Point relative to Centre2]

So know where Centre is and if we can calculate where Centre2 is relative to Centre and similarly where Point is relative to Centre2, we can just add them all together!

Given an angle and a distance, can we get a location?

The answer to this is a resounding “yes”! Look at the diagram:

Screen Shot 2018-01-30 at 17.56.34

given an angle and a radius, we can calculate the X and Y position of any point around a circle. The magic is the COS and SIN (pronounced “kos” and “sign”) functions. These functions exist in almost all programming languages and JavaScript’s no exception.

Using p5.Vector

The last big concept we tackled thus week was using P5js’s built-in vector class to store (x, y) points and make our code tidier. To make a vector we just use createVector(x, y). We can then use functions to add them together, etc. We would get the same result working with the X and Y values separately but the code is a lot neater and shorter.

And in conclusion

This looks pretty cool:

 

Getting this week’s code

As aways, all the code from our Creator group can be found on our GitHub repository.

 

Explorers – Week 3 2018- Maths Game

Another great week, a lot of work was done in the Explorers room. Hope you all had fun making our Maths game!

CDA-S5-Challenge_10-Maths game-how to

A player picks a level of difficulty and the computer chooses 2 random numbers to add (subtract or multiply- whichever you choose!) together and show the numbers to the player. Fr this we needed 2 SPRITES and 4 VARIABLES called SCORE, LEVEL, NUMBER1 and NUMBER2 as well as 2 BACKDROPS. CDA-S5-Challenge_10-Maths game-ask questions1CDA-S5-Challenge_10-Maths game-ask questions

The player then has to enter an answer to the equation and the computer tells them whether they are wrong or right. CDA-S5-Challenge_10-Maths game-decisions alternative end

We repeated the ask/answer questions 5 or 10 times. Can you figure out where the REPEAT loop fits?

We also had a second sprite who reacted positively to correct answers BROADCAST and negatively to wrong answers BROADCAST. You can use whatever sprites you like and change their look whatever way you like. One coder added a puppy as their second and had him bark whenever an answer was correct. CDA-S5-Challenge_10-Maths game-sprite 2

After all the questions were asked we had the 1st Sprite SAY – Game Over! and BROADCAST Game over so that the backdrop changed and music played. There are two ways to change the backdrop- see below!CDA-S5-Challenge_10-Maths game-alt backdrop CDA-S5-Challenge_10-Maths game-backdropHere are this weeks notes in PDF CDA-S7-Week_3_18-MathsGame.pdf

Also I have uploaded the finished game to the www.Scratch.mit.edu website, just use the login details in the notes.

See you next week

 

Martha

Bodgers – More SenseHAT

Hello again Everyone.

This week we continued to play with the Sense HAT and as we’ve been mostly focusing on projects so far this year we took the opportunity to look at some of the theory behind programming.

We looked at how we use variables, loops and decisions in our programs and we also learned about algorithms. An algorithm is a set of rules we can use to solve a problem for example an algorithm to determine if a given year is a leap year. A year is a leap year if it is divisible by four, but not by one hundred, unless it is divisible by four hundred.

We then worked on a program which would allow us to “move” an LED around the LED matrix on the Sense HAT. You can run our code on the trinket.io Sense HAT emulator.

Dave will lead the group next week when he will cover some basic electronics.

Thanks.

Declan, Dave and Alaidh.

 

Bodgers – Prizes and Plans

It was great to see everybody back after the break.

I had a big box of goodies from the recent Raspberry Pi Pioneers competition. We got more swag for both teams that entered including some very nice badges and three really interesting books.

Our Zombie Trolls also got their prize for failing really well 😊. This included a Raspberry Pi, a 5” HDMI Monitor, some basic electronic components, t-shirts and an Astro Pi Sense Hat (Hat stands for ‘Hardware Attached on Top’).

The Sense HAT add-on board was specially created for the Astro Pi competition which gives kids the chance to get their code running on one of two Raspberry Pi devices that are on the International Space Station.Astro_Pi_Ed_and_Izzy_on_the_ISS

The board gives Astro Pi the ability to ‘sense’ and make many kinds of measurements, from temperature to movement, and to output information using a special display – the 8×8 LED matrix. We had great fun playing around with the Sense Hat and it’s definitely something we will get great use out of and maybe we could enter the Astro Pi competition and have our code running on the ISS.

We also took a look at controlling an Arduino from Unity 3D which is something that could be used for 4D/Immersive Technology type game.

See you all next week.

Declan, Dave and Alaidh

 

Week 1 2018 Explorers – Breakout Game

Hi everyone,

Thanks to everyone who came yesterday and special welcome to our new people. Thank you all for your patience with the projector!

This week we did a game based on an old game called Breakout.

The object of the game is to try and get rid of all the blocks by bouncing a ball into them using a bat of some type. You all had your own versions of what you wanted the game to look that and that’s brilliant, your imagination is way better than mine.

The first thing we did was design your bat and write some code to control it. We decided that the mouse should control the movement and that the movement should be only from left to right and vice versa.

The rest of the code and notes for the game can be found here in PDF CDA-S7-Week_01_18-Breakout.pdf

I have also uploaded the finished game to the Scratch Website if anybody wants to take a look at it or for anyone that wasn’t there on Saturday. I will go through  it at the beginning of next weeks session if anyone has any questions.

You will find the login details for our account on the Scratch website in the notes above.

 

See you all next week and have a great week.

 

Martha