## Have a go at coding…

Learning to code is for everyone and it is fun, create digital art, make games, explore AI, IoT and robotics.

This is an opportunity to have a go at coding, you don’t need to understand it but you can learn through doing. If you want to learn how to code then I have a course for you as a series of eBooks (kindle on Amazon) which you can use on any device (you don’t need a kindle) even your phone. Click on this link https://www.amazon.co.uk/dp/B09KPVLBL1 for the first book in the series or visit the home page on www.thehappycoder.org.

Here you can have a go by typing in the code and running it. These are just coding snippets or doodles. So if you have never coded before here is your chance to try for free. You can’t fail, you can only try. Just follow the instruction below:

1. delete to code that is already there below,
2. type the code that is below,
3. take care to do it exactly as shown,
4. Press the play button,
5. try changing things to see what happens,
6. that is the best way to learn, play, experiment and try things.

## …now add this code

```let x = 200
let y = 200
let xvelocity = 8
let yvelocity = 5
let Red = 255
let Green = 255
let Blue = 255```
```function setup()
{
createCanvas(400, 400)
}```
```function draw()
{
background(100)
fill(Red, Green, Blue)
circle(x, y, 50)
x = x + xvelocity
y = y + yvelocity
edges()
}```
```function edges()
{
if(x < 25 || x > width - 25)
{
xvelocity = -xvelocity
Red = random(255)
Green = random(255)
Blue = random(255)
}
if(y < 25 || y > height - 25)
{
yvelocity = - yvelocity
Red = random(255)
Green = random(255)
Blue = random(255)
}
}```