2

I have recently bought a Raspberry Pi 2 for my term project but I have no experience at all. So far, I had been looking for tutorials but I am not sure they are talking about what I want to do (they connect Raspberry Pi to a screen and install an operating system to it, I think. I'm not sure that is a must or if they just want to use it like a computer, that's why I didn't want to blindly follow anything and Im explicitly asking it now).

I want to know how to program it from scratch. I have Windows and I also can run Ubuntu on virtual box. What do I do to, say, make a LED blink on a particular pin, while avoiding functions that I will not use (like installing an operating system if it is not good for my goal)?

Lets make the question as specific as possible:

How do I blink a LED using Windows or Ubuntu assuming my Raspberry Pi is new? (it has no setup, if it needs any)

Do I just write a python code and save it something like main.py and upload it to a SD card? How does it recognize which code to run? How does this work?

closed as too broad by Ghanima, Milliways, mpromonet, ArchHaskeller, Patrick Cook Oct 23 '15 at 17:26

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Step 1: You do need to install an operating system. – goldilocks Oct 17 '15 at 19:46
  • As goldilocks says above, you need an OS running, as the Pi is a fully fledged computer. You seem to be thinking that it is the same as a microcontroller, such as an Arduino (or BeagleBone or what have you), where only a few lines of code will suffice. Unfortunately this is not the case. Well done for asking the question though - as a newbie it is easy to have misconceptions about the Pi. :-) – Greenonline Oct 18 '15 at 21:45
  • Yeah it seems I got the whole picture wrong :) thats why I was hesitant to install the operating system. Thanks for the insight! – ozgeneral Oct 19 '15 at 7:05
4

You seem to have some misconceptions about what a Raspberry Pi is. A Raspberry Pi is a proper computer (as in: it has a processor and a GPU, memory, input and output connectors) which, just like your Windows and Ubuntu machines, needs an Operating System to do anything at all. That OS can be simple or complex, but most OSes available have a default GUI for you to work with (but can be configured to give you a text-based login as well). Then, once you have an OS up and running, the RPi allows you to connect to external hardware using the GPIO, for which it has a range of tools available (RPI.GPIO is just one example for when you'd like to program using Python). This is where the RPi differs from a normal computer - the availability of GPIO pins (combined with 5V, 3V3 and GND) to interact with external devices.

If you want a device to which you just upload some code and it interacts with external hardware, you might want to look at Arduino (and its clones), this type of device has a microcontroller (not a microprocessor, though the difference is sort of theoretical) on it which does not need an operating system to function. You write your code on another device (e.g. your computer), connect the Arduino, flash your code to it, and voila! it runs.

  • I did not choose arduino or any other microcontroller because I will make an image processing project. Since raspberry pi was 900MHz, I thought it would work significantly faster just with a slight increase in price. Honestly I had no idea it actually was a computer. I have one follow up question if you do not mind. Since it will run an OS in the background along with my code, does that mean the given speed of 900MHz will significantly decrease due to background operations? What net speed of execution should I expect for my codes? Is there any specific OS for my purposes? – ozgeneral Oct 19 '15 at 7:12
  • @OE1: I would ask this as a new question, but give specific examples (e.g. what needs to run at 900Mhz? Simple code execution? Or are you looking for 900Mhz signal frequencies on the GPIO?). Note that just like the original Pi, the RPi2 is overclockable to at least 1Ghz (fanless). – Phil B. Oct 19 '15 at 12:23
  • Yes I just need to execute a single code and not anything else if possible. I just asked it in a new question but someone thinks this belongs to cs. I would still appreciate if you have any insight you could provide though. – ozgeneral Oct 19 '15 at 16:36
3

You have a lot of choices to learn Raspberry Pi! First of all, the original website is very perfect and enough for that:

  1. https://www.raspberrypi.org/resources/learn/

Also some blogs are available to teach you how to program and how to do someting with Raspberry Pi to do. This website shows daily usage of Raspberry Pi:

  1. http://www.onuryolal.com/f/b/raspberrypi.html

And, please search any question on Google to do someting very quick!

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