Help me get started with Raspberry Pi and programming!
December 13, 2020 6:01 PM   Subscribe

Where do I even begin if I want to learn how to program one of these miniature computers? What language/software am I learning? What starter kit should I buy?

I have an idea for a project that includes pushing a couple of buttons, then some kind of programming, and then the result is a small LED lighting up.

I have not done any programming since BASIC and Pascal in high school -- like a million years ago. I am somewhat intimidated by learning a new programming language. I do not even know what languages those miniature computers use. I know that I can buy starter kits for Pi Zero and the like from places like Adafruit, but that is as much as I know.

Any tips or tutorials for folks like me that need to start from essentially ground zero?
posted by yet.another.boston.question to Computers & Internet (13 answers total) 21 users marked this as a favorite
 
Try Lady Ada -- her Arduino intro can, at a minimum, get you started with the flashing LED.
posted by Rash at 6:08 PM on December 13, 2020 [5 favorites]


The Arduino environment is set up to be easy to learn and teach. It uses C++ but doesn’t make you learn all the hairy stuff unless you want to do hairy things. There’s an enormous amount of tutorials, and you will be able to get up and running quickly even if you have no programming experience.

I haven’t used circuit python but it’s a similar system that’s allegedly even easier. The actual python language is more different from Pascal than C++ is so maybe you could save a smidge of time but really neither one will present you with significant challenges in getting going - both systems are designed with novice programmers or non-programmers in mind and both do a good job of being accessible.

I haven’t used a raspberry pi for this stuff but it is also pretty popular and easy. I think python would be the easiest language to get going in there.

For any of these I second the recommendation for adafruit. They are committed to being helpful to beginners and like cool stuff and have good ethics and everything.
posted by aubilenon at 6:48 PM on December 13, 2020 [1 favorite]


Please don't buy the Raspberry Pi Zero. It's super-limited, and will disappoint you.

Either buy a Raspberry Pi 4B or a Raspberry Pi400 (the integrated keyboard one) from one of the Approved Resellers. The official starter kits are good, but don't include the electronics you might play with. Get a proper Raspberry Pi USB-C power supply (important!). Even if you get an SD card, I implore you to re-image it with the latest Raspberry Pi OS: it was just updated a few days ago, so anything you buy will be out of date. Raspberry Pi OS (32 bit) is the OS you want to run. No really: Raspberry Pi OS (32 bit) is the OS you want to run. Everything else doesn't have the community support.

I'd recommend setting your Raspberry Pi up as a small desktop computer, complete with monitor, keyboard and mouse. Getting straight into headless development on Linux might be too much of a jump.

You'll probably be programming in Python: it'll do everything you need until you know you've outgrown it. As for starting with the blinkenlights, here's the official How to use an LED with Raspberry Pi. It uses the very simple gpiozero library: I mean, can it get more simple than:
from gpiozero import LED
from time import sleep

led = LED(17)

while True:
    led.on()
    sleep(1)
    led.off()
    sleep(1)
That's LED on for a second, off for a second, forever.

Regarding Adafruit, they're a good supplier. But their programming has gone kinda off the rails. They're all about pushing their own confusing software libraries now (adafruit_blinka) that are causing all sorts of confusion for new users.
posted by scruss at 6:54 PM on December 13, 2020 [7 favorites]


Agree that you may want to look into Arduino for this, not a RPi. Both are solid options, but the Arduino will probably be simpler to deal with for something like "push a button, do some math, blink some lights."
posted by Alterscape at 9:55 PM on December 13, 2020


And if you'd get the hang of an Arduino the logical next step from there is probably a Wenos D1 clone - think of it as an Arduino with WiFi, whenever you get to the point that networking is important.

I also strongly recommend against interacting with the physical world using a Pi. It can do it, but it's a difficult tool to use. I never have, since the alternatives are generally better suited.
posted by How much is that froggie in the window at 11:32 PM on December 13, 2020 [1 favorite]


Where do ESP32s and the like fit against the Pi and Arduino ecosystems in terms of ease of use and accessibility for n00bs?
posted by wenestvedt at 5:19 AM on December 14, 2020 [1 favorite]


I'd describe ESP32 as "somewhat more fiddly than an Arduino-branded Arduino, but also pretty approachable" but that may be my own biases and experiences speaking. I've got a few sensor/LAN-of-things projects going, but mostly go to Teensy or Arduino for most of my needs, since a lot of what I do is 'USB HID devices.' As far as position re: Arduino and RPi, I'd say the ESP chips are more of a microcontroller like an Arduino-family device that happens to have wifi than a computer you can connect a monitor/keyboard to, like the Raspberry Pi family.

There are at least two beginner-friendly ways to program an ESP32: CircuitPython and Arduino. CircuitPython uses, well, Python, and you can buy ESPs with the interpreter already flashed, or flash it yourself (moderately fiddly, but do-able if you are moderately computer savvy and can follow instructions). Arduino requires you to set up an Arduino-for-ESP package (by copying some text into the Arduino preferences) and figure out/select the correct board to target. At that point, you can write C/C++ code using Arduino idioms pretty directly. I personally prefer the C-flavored route since it's a skill that generalizes better off Arduino, but if you don't have any interest in other embedded development and do know/want to know Python, CircuitPython might be a rewarding way to go.

The ESP chips have fewer GPIO (general purpose input/output) pins than many Arduinos, and can be more finicky about input voltages, but more support for peripheral interfaces than most of the cheaper AVR-based Arduinos. So you can connect more advanced stuff like I2C devices, but not as many buttons/LEDs directly to pins on the device.

The good news is, ESP board are cheap -- last time I bought one they were $10-$15 each on Amazon, so if you're already fiddling with microcontrollers and have protoboards, random components/hookup wire/etc, it's pretty inexpensive to try them out!
posted by Alterscape at 6:33 AM on December 14, 2020 [2 favorites]


I'd suggest doing this in stages. First before you buy anything, learn a little bit of python. Once you've mastered the basics, pick up a raspberry pi 4/400 and learn how to install and use Pi-OS, and then learn how to run python on it. Then when you are comfortable with that, pick up a "starter kit" of components (for example) and start learning how to wire things up and control them from python. I think trying to learn all these things at the same is a recipe for frustration.
posted by Poldo at 7:31 AM on December 14, 2020


Response by poster: Hi All! Thank you for these great answers!

I will admit that I believe I was conflating Raspberry Pi and Arduino. It does look (to my very untrained eyes) that Arduino is better designed for simple/fun tasks like making lights blink. If I remove Pi-related devices from my possible choices, are there Arduino kits a newbie should look at?
posted by yet.another.boston.question at 8:12 AM on December 14, 2020 [2 favorites]


I tried to find a starter kit on Adafruit but it looks like everything they had is sold out for now. This knockoff came up as one of the first hits for "Arduino starter kit" on Amazon and it looks like it has most of what you'd want: an Arduino dev board, some prototyping boards (the white plastic boards with lots of holes), some LEDs, some switches, some hookup wire, some random sensors and actuators you might want to play with later.

Main thing it doesn't include that I feel like you'd want almost immediately is a multimeter (a tool for measuring current/voltage/resistance in electrical circuits; useful for checking your work), but I suspect for the sort of simple stuff you're doing you can probably live without one. If you do need one, you do not need to spend a lot of money. You can always upgrade to better tools later, when you need them! You'll also probably find yourself wanting wire strippers, diagonal cutters, and some soldering tools eventually, but that's a separate AskMe. :)
posted by Alterscape at 8:43 AM on December 14, 2020


are there Arduino kits a newbie should look at?

Alterscape's suggestion is a good one if you want lots for cheap. The Official Arduino Starter Kit is really expensive, but the quality of the parts and the excellent guidebook make it a great experience.

But another suggestion: Adafruit's Circuit Playground Express. Arduino — the platform, and the first generation hardware — is getting a bit tired. The Circuit Playground Express uses a 32-bit ARM microcontroller, can be programmed in CircuitPython just by saving the program file to the device from a standard editor, and comes with a bunch of sensors, LEDs and outputs. While the code might not run as fast as on an Arduino, the interpreted CircuitPython code is much easier to understand. It's a delightful package, and one I reach for a lot for trying out silly ideas quickly.
posted by scruss at 4:04 PM on December 14, 2020


Please don't buy the Raspberry Pi Zero. It's super-limited, and will disappoint you.

I dunno; I'm using a Pi Zero WH + a Unicorn Hat Mini for headless blinky-lights stuff -- currently, pulling local AQI data from purpleair.com and graphing it on the LED matrix -- and it's been great for that.

But a Pi's a little Linux box and if you're not at least somewhat familiar with Linux that's another thing you'll spend time learning to get your project up and running; whereas it feels like Arduino etc are much more geared to getting you playing with hardware ASAP.

I've been vaguely toying with getting one of the Arduino clone starter kits to play with, but I think scruss just successfully sold me on a Circuit Playground Express.
posted by We had a deal, Kyle at 6:55 PM on December 14, 2020 [1 favorite]


I built up a basic Arduino kit for my students this year from DigiKey : https://www.digikey.com/short/z1ff43 It doesn't come with a book, but you can fine everything you need online (PM me and I can share some syllabi and videos if you're interested).

The Official Arduino Starter kit is, as noted, $$, but it comes with a book and fun extras to get the projects looking good (full disclosure, I designed the tutorials and wrote the examples for that kit - but I'm not receiving royalties or anything).
posted by tip120 at 8:20 AM on December 20, 2020 [1 favorite]


« Older Crossword clue says to "unscramble letters"   |   Can I soundproof a walk-in closet to make a music... Newer »
This thread is closed to new comments.