Getting Started with Arduino

5 Minute Start

  1. Download the Arduino IDE version 1.0.5.
  2. Connect Arduino module to computer via USB cable
  3. Snap power module + battery and cable to any of the 3 inputs on the Arduino module [USB does not power module].
  4. Snap together any needed input, output or wire modules.
  5. Upload sketch!

Step by Step Tutorial

The first thing you will need to do is download the Arduino IDE (Integrated Development Environment). This is the software program used to write code (“sketches” in Arduino terms) and upload it to the Arduino module. The Arduino IDE is free to download and can be found here, both for Mac and PC.

Once you’ve installed the Arduino IDE, you can open up a sketch and start coding. If you are new to programming, we recommend you go through some of the sketch project tutorials we have posted. Start with the Blink sketch for example.

Once you have the sketch window open, you can connect your Arduino module to the computer via a micro USB cable. Unlike conventional Arduino boards, the USB connection only provides a data connection. Like all littleBits modules, the Arduino module requires a power module to function. This includes when you are uploading a sketch.

With the Arduino module powered, the computer should now recognize a connection and you might see the RX LED flash. You’ll now need to select what kind of Arduino you are using in the menu bar. Go to the “Tools” drop down in the menu bar and select Arduino Leonardo in the “Boards” section.

Now select the serial port the Arduino will communicate over by going back to “Tools” and selecting the correct port in the “Port” section. The name of the port will depend if you are on a Mac or Windows computer. On a Mac, it will start with /dev/tty.usbmodem… and a PC will start with COMM… In Windows, you can look for the USB serial device in the ports section of the Windows Device Manager. If you are on a Linux machine, the port will look like /dev/ttyUSB…

Once these are selected, you simply need to press the “Upload” button in the toolbar at the top of the sketch window.

Detailed information about navigating the Arduino IDE can be found here.

When you start uploading, you will see a message that says “Compiling sketch…”, then the message will read “Uploading…”. The TX and RX LEDs should flash and the message will read “Done uploading.” Uploading the sketch shouldn’t take more than 10 seconds.

Occasionally the uploading process gets hung up. Click the Upload button again and it will restart the upload process. On some occasions, there will be an error. You can read the debug message to solve the issue.

Powering your littleBits Arduino Module

Unlike conventional Arduino boards, the USB connection only provides a data connection so a littleBits power module is still required. Like any littleBits circuit, you can place an input module after the power to alter the signal before it gets to the Arduino module. Using multiple inputs at one time means you’ll need a fork or branch to supply power to the other input modules that comes before the Arduino module.


littleBits Arduino module Pins and Features

There are six microcontroller pins connected to our bitSnap™ connectors. On one side of the board, there are three input bitSnaps™. They are refered to as D0, A0, and A1 in the Arduino environment. D0 is a digital pin that is also a Serial input (known as RX). A0 and A1 are analog inputs that can also be used as digital inputs.

The other side of the board features three output bitSnaps™. D1 is a digital pin that is also a Serial out (known as TX). D5~ and D9~ are PWM outputs that are also capable of simulating an analog DC voltage (more on that later).

Both the TX and RX pins have LEDs associated with them so show the status of Serial communication between the board and the computer.

For advanced Arduino users, we added a few features that can be taken advantage of and offer connections not previosly offered on a littleBits module. They are:

I2C - The top side of the PCB has two pads which break out pins D2 and D3 from the ATmega32U4. These are the SDA and SDL lines used in I2C communications so multiple boards can be chained together. There are unpopulated pads for 10K pull up resistors if I2C implementation is needed. These pins can also be used as GPIO.

ICSP - There is a standard ICSP connection in the form of through holes that can be soldered to with jumper wires or male/female headers. The bootloader can be updated/changed through these pins and programs can be uploaded via a AVR programmer.

Analog GPIO - Pins A2, A3, and A4 are available in the form of through holes that can be soldered to with jumper wires or male/female headers.

Digital GPIO - Pins D10, D11, and D13 are available in the form of through holes that can be soldered to with jumper wires or male/female headers.

2 Likes

This is a really helpful post. Thanks very much! I think it would be helpful to add details about the two switches, and what the significance of analog versus pwm is. Also, I am wondering if the analog/pwm choice means that I can harm some of my bits if they are connected with the switch in the wrong position-- is the the case? I apologize if these questions are too basic-- I am very new to Arduino. Also, it might be good to edit all the starter Arduino projects to contain what position the two switches should be in for each project-- just in case the user is worried about it or someone has unexpectedly changed the switches.

That is a great question! I will do a brief explanation of the difference between PWM and analog signal.

The key to understanding this difference is to understand the difference between digital and analog electronics:

An analog signal generally refers to the voltage of a signal at a certain time. It is implied that through various electronic components, we can manipulate these signals to represent any voltage between 0 volts and the voltage of our power source. In littleBits this voltage is 5V. An analog signal could be a sine wave such as one in the following picture:

When a signal is said to be digital, it can generally only represent two values, high and low (or as a computer would interpret it, 1 or 0). In the scope of Arduino, the microcontroller it uses can only output a high value or a low value. It cannot for example, output 2.5V (midway between high and low). In order to compensate for this lack of versatility, it uses what is known as a PWM, or pulse-width modulated, signal.

A pulse-width modulated signal is a digital signal that over a short fixed time interval that will keep the signal low for a percent of the time and the signal high for a percent of the time such that the average signal will be of desired value. Have a look at the figure below.

The blue is a representation of a PWM signal. Notice that it only goes high or low and never has a value in between. Every 1000 samples on the x-axis represents one PWM cycle. When you program your Arduino you can change the length of this cycle, but perhaps more importantly you can tell it for what percent of each cycle you would like the signal to be high for. In the Arduino you will set a value between 0 and 255 to represent this. For this example we set it to 51 which is 20% of 255, so for every cycle the signal goes high for 20% of the time. If we are to take the average value of this cycle (sum each of the 1000 samples and divide by 1000) we would get an average voltage of 1V.

So let’s bring this back to the switch on your Arduino module which allows you to select between the two. when you have PWM mode selected you will be getting that periodic high/low signal described above. When you switch it to analog mode, you are actually rerouting that PWM signal through some additionally circuitry before it leaves the module. This circuitry (in this case a low-pass filter) converts that PWM signal to the average value of the PWM signal so your output signal will look like the dashed red line rathern than the blue line.

If you have a bar graph bit, you can use the default code for the Arduino module to see the difference in action. If you program a PWM output to ramp up and down repeatedly you will see all LEDs on the bargraph slowly get brighter and dimmer, all at the same time. If you are to then switch it to analog analog mode you will see each LED turn on in succession and then turn off in succession, all with the same brightness.

As for damaging other bits by accidentally hitting the switch, we have taken many measures to make sure you can experiment to your hearts content without fear of damaging your bits, so fear not!

Hopefully this helps! Let us know if you have any other questions.

1 Like

Thanks very much! That is a very helpful description. I am looking forward to experimenting with both PWM and analog settings. Thanks again!

So with the d10, d11, d13 and the a3, a4, a5 through holes, does that mean we can have up to 6 additional inputs or outputs? I’m new to arduino, and I just got my littleBits arduino yesterday. However, I’m adventurous. I’m super excited about these through holes adding extra outputs!

Hi JackANDJude,

The six labeled through-holes you mentioned are connected to the microcontroller and can be used as additional inputs/outputs. We left those on the board so that those who are comfortable with soldering can have access to more pins if they need them! Just for clarity, the labels are referring to the outer pins. The inner six pins are intended for ISP programming.

If you end up using those extra pins, take pictures and let us know what cool projects you come up with!

-Sean

Thanks, Sean! I did use extra pins for my project, which I posted on the community projects page entitled “Animated Grasshopper Jumping”. I’m calling the top left of the six ICSP pins GND, because that’s what I discovered with my voltmeter.

Nice! Thank you for sharing!

Are the a3, a4, and a5 input only, and the d10, d11 and d13 output only, or can both sets be input or output?

Hi JackANDJude,

Those pins can be used as either inputs or outputs as long as you set them as so in your code. For example:

pinMode(A3, OUTPUT);
digitalWrite(A3, HIGH);

-Sean

1 Like

littleBits DC motor direction control?
DC motor + slide dimmer/dimmer + Arduino module + inverter
may I control the DC motor direction?
the Arduino module is receiving 0-255 from the dimmer so I should program it to raise 1 output when dimmer input is 0-127 and another one when dimmer input is 128-255. Consequently, the DC motor should be supplied by 2 lines downstream the Arduino module: one ON while the other is OFF and vice versa after the dimmer status said before. One of them has an inverter: does the inverter change wires’ polarity? If not, are there other ways to control the DC motor direction in littleBits?

P.S.
a) I am thinking I might hard-wire one of the DC motor’s supply lines oppositely to the other but is this allowed by littleBits modules?
b) I also found this tutorial from instructables: Simple-2-way-motor-control-for-the-arduino
is the method described in the tutorial advisable?

Thanks

LittleBitsZaa - You cannot change the motor direction of a littleBits DC motor electronically. If you are determined, your options are to hack or be creative. I don’t know what your project entails, but get a look at the Robot Butler project by littleBits, which I would count as a creative solution. They used two DC motors and a ball caster to make a robot that can change direction, and they did it without changing direction of the motors themselves.

I agree what I am trying here would require the Servo Module (stepper motor). But it seems it is turning too slowly for my application. Maybe some extra mechanics would take it to the needed speed (reducing torque) but that adds complexity to the project.

I also agree that the “electronic” way is tough meaning the PWM control described in the mentioned instructables tutorial may give troubles. But what about the other approach I was thinking about i.e. the “electric” mode.

I am waiting for the littleBits DC Motor Module but I tried a little experiment with other Modules I already have in house.
I used the Power Module + Slide Dimmer. Then I hard-wired the Slide Dimmer to a small DC motor I had in house. As expected, if I invert the wires at the motor terminals, the motor changes direction and I can even reduce its speed by means of the Slide Dimmer. In the end, everything would be just fine if I were able to supply the motor through 2 littleBits Module lines, one inverted with respect to the other, and programmatically switch between them. Is there really no way to do it without hacking littleBits Modules?

The littleBits DC motor has more hardware on it than simply a DC motor. In between the bitsnap male connector and the motor terminals there is an op amp chip, a mosfet driver and a slide switch. I am not sure what will happen if you switch your littleBits terminals, but I think it is worth looking at the schematic and researching op amps and their mosfet driver chip before you try your idea. A good idea is to simply attach the small DC motor you have in house to your littleBits Arduino module. There are extra pin holes on the Arduino module for adventurous folks like us. Here is the diagram for the DC motor: https://github.com/littlebitselectronics/eagle-files/raw/master/OUTPUT/LB_BIT_o5_DCMOTOR/LB_BIT_o5_DCMOTOR-v03(rev1)/LB_BIT_o5_DCMOTOR-v03(rev1).pdf

nope,
in the diagram of the DC Motor Module you linked, having it supplied reversely would mean to replace all VCC with GND and vice versa. The whole circuitry before the motor would not work that way meaning the

  1. op-amp supply voltage terminals;
  2. 4.7uF electrolytic capacitor;
  3. MOSFET driver supply voltage vcc (pin 6);

I also dug a bit into the Inverter Module. Looking at its diagram and the datasheet of the SN74AHC1G04, it is now clear that the Module acts like a logic inverter on SIG leaving VCC and GND unaltered.

Thanks for your hints.

I’ve run into an early problem. On my MacBook, when I run Arduino, no serial port starting /dev/tty.usbmodem appears in the list. (The computer does have USB ports.) The ports available all start /dev/tty.Bluetooth, except for two: /dev/tty.SGH-390G-SerialPort and /dev/cu.SGH-390G-SerialPort. I tried those, but neither works. Basically, any port I try, I get the error message that that port is in use.

? ? ?

Jon C.

see this thread

Thanks for the reply. One error was that I thought the Arduino program would recognize the USB port even without the Arduino board powered.

I have the Little Bits Arduino at heart board.

Now, I am able to see the port once the board is powered on.

It still does do something odd… when I upload the sketch to the board, the computer behaves as if I plugged in a keyboard. I.e., the Mac OS brings up a screen asking me to identify the keyboard just plugged in. It doesn’t seem to interfere with the operation of the Arduino board otherwise… but I admit I don’t have a very good way to ‘test’ things (from lack of grasp!).

I think, putting that anomaly to the side, that it works… the sketch presently seems to be driving the board, and it is transmitting what the code instructs to further bits of circuitry.

Try what suggested at this page (at your own risk, meaning I don’t have a Mac and I have not tested the Arduino Module on my Windows yet)
http://hints.macworld.com/article.php?story=20100123161902792

I am confused about how to connect the P1 module to the Arduino. I can use the cable to connect the Arduino module to the computer, but where is the P1 module connected. A diagram would be helpful.

Chuck