How to learn how to code


#1

As being able to code is soon to become a vital skill in society I thought it would be nice to have a place where people can recommend and discuss learning to code.

At the time of writing I am a 13 year old who can code:

Python, Arduino, VB console, HTML & CSS and I have a rough knowledge of the paralax propeller language.

I learnt to code the top down method.

This is where you take a piece of code say one of the unicornhat examples:

import time

import unicornhat as unicorn

print("""Simple
Turns each pixel on in turn and updates the display.
If you're using a Unicorn HAT and only half the screen lights up, 
edit this example and  change 'unicorn.AUTO' to 'unicorn.HAT' below.
""")

unicorn.set_layout(unicorn.AUTO)
unicorn.rotation(0)
unicorn.brightness(0.5)
width,height=unicorn.get_shape()


for y in range(height):
  for x in range(width):
    unicorn.set_pixel(x,y,255,0,255)
    unicorn.show()
    time.sleep(0.05)

time.sleep(1)

and you fiddle around changing things and seeing what breaks for example you could change the time.sleep value and find that it becomes faster or slower.

or the colour by changing

unicorn.set_pixel(x,y,255,0,255)

and after playing around you will have learnt and worked out for yourself about RGB colour values.

Another way to learn would be the bottom up learning.

This is quite a popular method in schools and code clubs although that is changing as can be seen in bilge tank 069

You can go to
https://learn.pimoroni.com/
https://learn.adafruit.com/
https://learn.sparkfun.com/
https://raspberrypi.org/resources
where you can choose from many tutorials that will guide you through the basics of the programming library and it is very beginner friendly.

https://codeacademy.com is a great place for this style as well

There is also the Do a project way

This quite simple to explain you want to do something so you just do it and every time you hit a boundary you go to somewhere like stackoverflow or you look it up in the docs for example.

http://docs.pimoroni.com/
https://github.com/adafruit
https://github.com/sparkfun

I hope that helps newbies looking for a way to start.

Below are some links to great websites or books that people have recommend or that I have found useful

https://multiwingspan.co.uk
https://www.adafruit.com/category/40
https://www.arduino.cc/en/Reference/HomePage


#2

Old thread, but seeing as you didn’t get any replies I’ll bump it up and add a bit of my own personal experience to it.

I’m almost 60 and only learned to code in python in the last couple of years. I’m no expert, but I’m no noob either, lol. The Raspberry PI foundation will be happy as it was the purchase on my first Raspberry PI that started me coding. I happened on Python because most of the tutorials and examples were in python. I learned by trial and error, syntax error mostly, lol.

I’m a retired electronic technician. That lead me to playing around with sensors etc. Breakout boards that usually used i2c. Some GPIO stuff too. Lots of different things. It’s been loads of fun, and frustrating at the same time. More fun though, =)


#3

I think I learned the most from a weather clock project I did. A Pi A+, Sense Hat, and SI1145 light sensor. I highly recommend anybody that’s not sure what they want to do to give the Sense Hat a consideration. IMHO you get a lot of bang for your buck. Temp, humidity, barometric pressure sensors onboard. Plus magnetometer and gyro’s, and an 8 x 8 RGB LED matrix. It was good enough for the International space station. https://astro-pi.org/