Can you actually write a program to a Raspberry Pi 2 like we normally do with microcontrollers? I'm only seeing videos of Raspberry Pi's connected with a computer, and it seems like the actual program is being runned using the computer.

(this might be a very noob question) but can we actually write the program like we do with microcontrollers, so it doesn't has to be connected to a pc anymore. for example this video: https://www.youtube.com/watch?v=Bqk6M_XdIC0 Can i let this work without it's connected to the computer? just a simple program which allows you to light up a LED when a button is pushed.

& is this all well explained or showed when i will buy this raspberry pi?

  • Jonas

The Raspberry-Pi 2 can run programs without being connected to another computer. It normally runs it's own programs, and talks to other computers for similar reasons to any other PC or laptop.

Add a monitor+keyboard+mouse, and it can be used to write programs, to run on itself, or other compuers (like MCUs). So again, it doesn't need another computer. It normally runs a version of the Linux operating system, and much of the information on the web uses the Raspberry-Pi/Pi 2 that way.

I strongly recommend you go to the Raspberry-Pi web site and start searching around there instead of youtube. The YouTube videos don't seem to be communicating effectively.

You do not need to do 'bare metal' programming if all you want to do is light an LED when you push a button. There is much less information about using it this way (maybe 1%?).

Programs that run on Raspberry-Pi/Pi 2 can be developed in many different programming languages. Python is popular because it is easy to learn, but you could use C/C++, or many other programming languages.

The only instructions which come with a Raspberry-Pi are about going to the Raspberry-Pi web site, and learning from there.

If you want to drive an LED display 'wall' I recommend you look at Paul Stoffregren's work. He has several projects, including playing real-time video. He uses a small Cortex-M MCU to drive 1000 LEDs, and a BeagleBone Black for controlling many of the Cortex-M boards.

https://www.youtube.com/watch?v=M5XQLvFPcBM http://www.dorkbotpdx.org/blog/paul/maker_faire_2013

Edit: I think trying to drive 64x64 (4096) RGB LEDs directly from a Raspberry-Pi/Pi 2, is not the way I'd go.

Each of the 4096 LEDs will need 24 data bits to update the picture
= 98,304 data bits The refresh rate of the WS2812 LEDs is about 800kbits/second, and it is very time sensitive, so
98,304/800,000 = 0.123 seconds
That is about 8 frames/second, so unusable for live video. They would be better driven as 4 independent displays.

I think it will be hard to drive 4 displays unless you did use the R-Pi bare metal, where everything will become much harder.

I like Paul Stoffrgren's approach because, not only it works, and he has proved it, but also because the hard real-time task of driving the LEDs (which would be hard to debug, or more precisely harder to fix if it doesn't work) is handled with a piece of hardware which is capable of the job, and easier to debug and fix.

A BeagleBone Black has two 'real time' processors called PRU's, which could be used to drive the LEDs. However, they might be quite complex to use, with very little help available.

Given your original question, which I interpret as an indication that you are not very experienced, I would suggest you investigate Paul Stoffregren's approach first. That works for 2048 LEDs, has the potential to drive more, and can be experimented with at a low initial cost. Doing some actual experiments that are likely to work is very helpful for discovering facts and building experience.

Edit 2:
I would tend to avoid anything which says Technical Details "We don't have a spec or datasheet at this time. However, these are the specifications from the factory", even from Adafruit, unless I really knew exactly how to use them.

Further, comments like "in theory you can chain these together", suggests they haven't tried, though it is exactly what you say you want to do, would not make me feel confident.

The only examples they have are for Arduino UNO and Mega. So use an Arduino MEGA. It has 8KiBytes RAM, which is enough for 12 bit colour for 2048 LEDs.

I would probably search the net for working code for more powerful processors, and base my choices on the that. Otherwise I'd probably use different LED technology.

  • Thank you very much, btw this is what i want to do: making an 64x64 rgb LED panel controlled by +- 9buttons as input to play games like tetris on the panel. using 4 of these panels: adafruit.com/products/607 chained to one, i should only be using 13 GPIO pins for the panel – JonasAnon Oct 10 '15 at 15:38
  • Please add that information to your question. – gbulmer Oct 10 '15 at 16:00
  • You did a lot of research but this is a 64x64 raspberry pi controlled rgb led panel, youtube.com/watch?v=i52IwH9loLU and it seems to work great? – JonasAnon Oct 10 '15 at 16:55
  • @JonasAnon Very good find! Add that link to your question. The adafruit panel you pointed to is 32x32. There is no spec on how fast or slow it can be driven. I assumed real-time video as a worst case, which is more than you need. I am very impressed that they say 100Hz refresh at 24 bit colour. For 32x32 LEDs, with 256 levels per colour, over only a 6 bit data bus, that is superb. for 256 updates/frame, for 'PWM' to the whole 32x32 (1024 LED) panel in 40 microseconds, or 26MHz, it's very good for 'bit bashing' data and address. Amazing for four panels – gbulmer Oct 10 '15 at 17:21
  • but now after seeing this video, can i use a raspberry pi or not? because what you're saying looks very interesting.. – JonasAnon Oct 10 '15 at 18:39

A Raspberry Pi is a complete computer in itself: you can connect a screen, keyboard and mouse to it, just like you would to a PC, and use the tools on it to create and run programs, again, just like you can on a PC. Lots of people do just that.

The second part of your question seems to be slightly different: can we run a program on a Pi like we do with microcontrollers. Yes, that is possible too, but this is done much less often. It is called bare-metal programming (without the Linux or other OS that is normally used.) But as far less people do this, there is far less info on this mode of programming, and the manufacturer of the main chip (broadcom) doesn't fully disclose all its chip info to the general public.

"is this all well explained or showed when I will buy this raspberry pi" When you buy a Pi you buy just that, the PCB with components. Everything there is to know about it you can know right now, by searching the web.

  • Thats what i want to do (the second part of my question), because i have to control a 64x64 rgb led panel AND i want to have a very big "program memory", this can't be done by a normal microcontroller because of the simple fact that i need a better processor. So the perfect solution would be using a Raspberry Pi with this perfect specifications. – JonasAnon Oct 10 '15 at 15:21
  • @JonasAnon Do note that it will most likely be much easier to just control the LED panel using a normal operating system than doing bare metal programming. Learning curve is going to be much steeper for something like R-Pi 2 compared to a regular microcontroller. – AndrejaKo Oct 10 '15 at 15:24
  • The Raspberry Pi doesn't have more IO than some big microcontrollers. Your challenge for your 64x64 array will likely be hardware multiplexing, and not software. – Scott Seidman Oct 10 '15 at 15:29
  • @AndrejaKo why is it different from a regular microcontroller? – JonasAnon Oct 10 '15 at 15:30
  • @JonasAnon Get a datasheet for say any of the PIC18F series and compare it to the documents for what we have in R-Pi 2. First, just compare number of pages! – AndrejaKo Oct 10 '15 at 15:32

What I suggest is to take the mid route between GNU Linux and bare-metal; namely write "bare metal" programs on Linux. There are plenty of libraries and examples out there that can talk to GPIO pins from many different languages, e.g. C, Python, etc. As long as you can access certain stdlibc calls like mmap and fopen /dev/mem, it's doable in any language. I once wrote a GPIO demo in Rust, which is a bit of an exotic language today.

Using linux has several advantages and disadvantages. The major disadvantage is you have to work with the OS to do anything with the hardware. This can often be done in userland (although programs need to run as root) with /dev/map file, which can have access to the complete physical memory map. From there you can read and write to the GPIO registers directly. Performance is quite good; I got a GPIO toggle speed of tens of MHz on the original RaspBerry PI.

Another disadvantage is the OS may switch context in your program at irregular intervals. This means programs are hard to get real-time at the very small time periods, because the Linux OS may briefly handle a daemon task or networking.

If you can't afford to miss e.g. 1ms continuously you're probably better off with a microcontroller instead (or Beaglebone Black PRU's)

However, a huge advantage by using Linux is you have full set of decent and free tools available. I mean; drivers for network, USB, file system, sound, graphics. GNU and Unix-like environment. Development toolchain; e.g. you can install SSH and remote access the device from your desktop. Use GCC and GDB toolchain on the RPi itself to compile & debug your code locally (or set up GDB to work over network)


A Pi is not a microcontroller - the ARM cpu it uses is a full microprocessor (a quad-core on the Pi2) with floating point hardware, the ability to use a lot of ram, blah,blah,blah. Just because it's so cheap you shouldn't think of it as some sort of PC adjunct or Arduino-like.

You can run full linux (the default is a Debian derivative) and develop using any gcc stuff (plus many other languages) or a minimal RTOS, or even do bare metal if you really want. The forums at raspberry.org cover all of them. You can even run RISC OS which is the only OS worth caring about (yeah, yeah, I know). I shudder to write it but you can even run the Windows 10 IoT kernel. Yuck, now I have to wash my hands.

So to your first question I have to say 'category error'. It's a little like misunderstanding what a car is and asking if you can pull it with a team of horses; sure you could but it isn't even slightly what you'd do in practice.

If your needs are not much bigger than lighting up an LED when a button is pushed then you'd really not need a Pi. It would be like using a Tesla as a golf cart. If you want a fairly powerful SBC that can do that and go on to do a whole lot more, maybe a Pi is the answer. A big practical factor is that a Pi is so cheap you may as well get one anyway.; you're going to have fun with it one way or another.

  • guy you're totally not answering my question, i'm asking if it's possible, if i'm asking for it, it would have their reasons isn't it? – JonasAnon Oct 11 '15 at 11:56

This platform uses an ARM processor which is really powerful.Due to the complicity of this processor you cannot program like a low performance microprocessor.Raspeberry is using a Linux or Android to manage the resources.You could use the linux platform and write programs for linux.This could be more "easy" for resource managment.You could search on google Yocto project for Rapeberry PI.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.