Tag Archives: ide

Installing Xamarin (Mac)

If you want to install Xamarin on Windows then go here. If you want to install Xamarin on Mac then watch the video below or scroll down to read the instructions.

The instructions below are for the Mac operating system installing all components. You can also view the official Xamarin instructions on installing Xamarin on Mac and Windows here.

Step 1

Download Xamarin from xamarin.com/download and locate the installer file once it has downloaded.

download

Make sure if you are developing iOS apps that you also have Xcode installed on your Mac. You can download Xcode from developer.apple.com/xcode. It may already be installed on your Mac but make sure you have the latest version.

xcodedownload

Step 2

Run the Xamarin installer and then double-click on the Xamarin icon to start the installation.

1installer

You may see an alert message like the one shown below. If you see the message below, click on Open.

2permission

Step 3

Review and accept the license to proceed with the installation. Check the box that says ‘I agree to the license terms‘ and then click on Continue.

3terms

Step 4

Now the installer will check if you already have any of the required components. It will then provide you with options to install any required components that are not already installed. Select the products you would like to install – this depends on what platforms you want to make native apps for.

If you want to make both Android and iOS apps, then select both Xamarin.Android and Xamarin.iOS. You can also select Mac if you want to develop Mac apps. Then click on Continue.

4selectproducts

Step 5

If you have chosen to install Xamarin.Android then you will be notified that the Android SDK needs to install. Click on Continue.

5androidsdk

You will then be shown all of the components that will be installed. Click on Continue to begin the installation.

6pre

Step 6

The Xamarin installer will begin downloading and installing the required components.

7installing

Hang around during the installation process because you may be asked to enter your password a few times to give permission to install the required components. Simply enter your password and click OK each time you see the message below.

8permission

Step 9

And you’re done! If you see the message below then Xamarin has successfully been installed on your computer. If something goes wrong or the installation fails, then you may see error messages (scroll down for more info). Once Xamarin has installed, you can run it from the Launchpad on your Mac.

9done

There are a few reasons why the installation could fail but one of the most common reasons is that your computer runs out of available storage space during the installation. To fix this, make some more space available by deleting unwanted files and then try installing Xamarin again – don’t worry, you shouldn’t have to start downloading everything from the beginning, just what didn’t get downloaded.

The next thing you should do if you intend to make and test Android apps, is to download and install the Xamarin Android Player. It is much faster for testing your apps than the built-in Virtual Device Manager.

Next tutorial: Hello world! (in C#)

Building a 2WD Arduino robotic car

This tutorial will show you how to use an Arduino to build a 2WD robotic car. You can extend this project by using sensors to measure wheel speed (for improved accuracy when steering or maintaining a straight line) or sensors to avoid objects or follow a line.

Parts required

Here is what you will need:

  • Arduino Uno board
  • 2WD robotic car kit (2 wheels, 2 motors, chassis)
  • 4 x AA batteries
  • Motor shield with 6 wires
  • Arduino IDE software (free at http://www.arduino.cc/)
  • USB cable
  • 2 x wheel speed encoders and infrared sensors (optional)

car1 car2 Assembling the robot

robotassembly

 

  1. Assemble all chassis parts and attach the motors to the wheels (if not already assembled).
  2. Connect the red wire from the battery enclosure to VIN on the Motor Shield.
  3. Connect the black wire from the battery enclosure to GND on the Motor Shield.
  4. Connect the red wire from Motor A to A+ on the Motor Shield, and the black wire from Motor A to A- on the Motor Shield.
  5. Connect the red wire from Motor B to B+ on the Motor Shield, and the black wire from Motor B to B- on the Motor Shield.
  6. Attach the Motor Shield to the top of the Arduino Uno board – be careful not to bend or damage any of the pins!
  7. Connect the Arduino Uno board to the computer via the USB cable and upload the code using the Arduino IDE software.
  8. Insert four AA batteries in the battery enclosure.
  9. Test your robot! If your robot goes in the wrong direction or doesn’t move, check that you have the Motor pins in the correct places and make sure no pins are loose.
Extra challenges:
  • Control your robotic car using an Android app on a smartphone via Bluetooth (refer to the Controlling an LED by Bluetooth tutorial for instructions on how to make an app using App Inventor and how to attach a Bluetooth module).
  • Add code that will control the speed of the motors using the encoder discs and infrared sensors.
The code to test your robot

Use this code to test that your wheels spin and that your robot is wired up correctly.

void setup() {
    //Setup Channel A
  pinMode(12, OUTPUT); //Initiates Motor Channel A pin
  pinMode(9, OUTPUT); //Initiates Brake Channel A pin
  //Setup Channel B
  pinMode(13, OUTPUT); //Initiates Motor Channel B pin
  pinMode(8, OUTPUT);  //Initiates Brake Channel B pin
  }
void loop(){
  //Motor A forward @ full speed
  digitalWrite(12, HIGH); //Establishes forward direction of Channel A
  digitalWrite(9, LOW);   //Disengage the Brake for Channel A
  analogWrite(3, 255);   //Spins the motor on Channel A at full speed
  //Motor B backward @ half speed
  digitalWrite(13, LOW);  //Establishes backward direction of Channel B
  digitalWrite(8, LOW);   //Disengage the Brake for Channel B
  analogWrite(11, 123);    //Spins the motor on Channel B at half speed
  delay(3000);
  digitalWrite(9, HIGH);  //Engage the Brake for Channel A
  digitalWrite(8, HIGH);  //Engage the Brake for Channel B
  delay(1000);
  //Motor A forward @ full speed
  digitalWrite(12, LOW);  //Establishes backward direction of Channel A
  digitalWrite(9, LOW);   //Disengage the Brake for Channel A
  analogWrite(3, 123);    //Spins the motor on Channel A at half speed
  //Motor B forward @ full speed
  digitalWrite(13, HIGH); //Establishes forward direction of Channel B
  digitalWrite(8, LOW);   //Disengage the Brake for Channel B
  analogWrite(11, 255);   //Spins the motor on Channel B at full speed
  delay(3000);
  digitalWrite(9, HIGH);  //Engage the Brake for Channel A
  digitalWrite(8, HIGH);  //Engage the Brake for Channel B
  delay(1000);
}

Click here if you would like a PDF copy of these instructions.

Arduino weather station project

This tutorial will show you how to take temperature readings using the Freetronics temperature sensor and an Arduino Uno.

Note that there are two different module types: the temperature sensor module and the humidity & temperature sensor module. If you have the humidity & temperature sensor module you will need to download a library for the Arduino IDE and use different wiring and code – follow the instructions for that module here: http://www.freetronics.com.au/pages/humid-humidity-temperature-sensor-module-quickstart-guide

Parts required

Here is what you will need:

  • Arduino Uno board
  • Temperature Sensor Module
  • Breadboard
  • 3 male-to-male jumper wires
  • Arduino IDE software (free at http://www.arduino.cc/)
  • USB cable

Wire it up!

tempwiring

 

Attach the temperature sensor module to your breadboard. The GND pin should connect the GND pin on the Arduino board, the VCC pin should connect the 5V pin on the Arduino board, and the DATA pin should connect to the digital I/O pin 2 on the Arduino board – all these are connected via the breadboard using male-to-male jumper wires.

The pictures below show how to wire it all up in greater detail.

tempwiring1 tempwiring2 tempwiring3

 

Arduino code

Here is the code for the Arduino sketch (you can also copy it from http://www.freetronics.com.au/pages/temp-temperature-sensor-module-quickstart-guide). Make sure you scroll down to see how to test the sensor.

#define REF_PIN 2
void getCurrentTemp( int *sign, int *whole, int *fract);
char temp_string[10];
void setup(){
  Serial.begin(9600);
  // initialize DS18B20 datapin
  digitalWrite(REF_PIN, LOW);
  pinMode(REF_PIN, INPUT);      // sets the digital pin as input (logic 1)
  pinMode(15, INPUT);
}
void loop(){
  getCurrentTemp(temp_string);
  Serial.println(temp_string);
  delay(1000);
}
void OneWireReset (int Pin) // reset.  Should improve to act as a presence pulse
{
  digitalWrite (Pin, LOW);
  pinMode (Pin, OUTPUT);        // bring low for 500 us
  delayMicroseconds (500);
  pinMode (Pin, INPUT);
  delayMicroseconds (500);
}
void OneWireOutByte (int Pin, byte d) // output byte d (least sig bit first).
{
  byte n;
 
  for (n=8; n!=0; n--)
  {
    if ((d & 0x01) == 1)  // test least sig bit
    {
      digitalWrite (Pin, LOW);
      pinMode (Pin, OUTPUT);
      delayMicroseconds (5);
      pinMode (Pin, INPUT);
      delayMicroseconds (60);
    }
    else
    {
      digitalWrite (Pin, LOW);
      pinMode (Pin, OUTPUT);
      delayMicroseconds (60);
      pinMode (Pin, INPUT);
    }
    d = d>>1; // now the next bit is in the least sig bit position.
  }
}
byte OneWireInByte (int Pin) // read byte, least sig byte first
{
  byte d, n, b;
 
  for (n=0; n<8; n++)   {     digitalWrite (Pin, LOW);     pinMode (Pin, OUTPUT);     delayMicroseconds (5);     pinMode (Pin, INPUT);     delayMicroseconds (5);     b = digitalRead (Pin);     delayMicroseconds (50);     d = (d >> 1) | (b<<7); // shift d to right and insert b in most sig bit position
  }
  return (d);
}
void getCurrentTemp (char *temp)
{
  int HighByte, LowByte, TReading, Tc_100, sign, whole, fract;
  OneWireReset (REF_PIN);
  OneWireOutByte (REF_PIN, 0xcc);
  OneWireOutByte (REF_PIN, 0x44); // perform temperature conversion, strong pullup for one sec
  OneWireReset (REF_PIN);
  OneWireOutByte (REF_PIN, 0xcc);
  OneWireOutByte (REF_PIN, 0xbe);
  LowByte = OneWireInByte (REF_PIN);
  HighByte = OneWireInByte (REF_PIN);
  TReading = (HighByte << 8) + LowByte;
  sign = TReading & 0x8000;  // test most sig bit
  if (sign) // negative
  {
    TReading = (TReading ^ 0xffff) + 1; // 2's comp
  }
  Tc_100 = (6 * TReading) + TReading / 4;    // multiply by (100 * 0.0625) or 6.25
 
  whole = Tc_100 / 100;  // separate off the whole and fractional portions
  fract = Tc_100 % 100;
 
  if (sign) {
    temp[0] = '-';
  } else {
    temp[0] = '+';
  }
 
  if (whole/100 == 0) {
    temp[1] = ' ';
  } else {
    temp[1] = whole/100+'0';
  }
  temp[2] = (whole-(whole/100)*100)/10 +'0' ;
  temp[3] = whole-(whole/10)*10 +'0';
  temp[4] = '.';
  temp[5] = fract/10 +'0';
  temp[6] = fract-(fract/10)*10 +'0';
  temp[7] = '\0';
}
Testing

Upload the code once you connect the Arduino to the computer with a USB cable. In the Arduino IDE, click on Tools > Serial Monitor. Make sure you change the baud rate to 9600 baud. The temperature sensor should have a constant blue light and the Serial Monitor should display the temperature readings every second.

temptesting temptesting2

Think about how you could use the temperature sensor. You can connect the Arduino to a dot-matrix or LCD display to display the temperature. It could also be used for climate control inside a room. How else could you use it?

Click here if you would like to download a PDF copy of these instructions.

Blinking LED Arduino project

This video tutorial has been designed for those just starting out with Arduino. For this beginner project you will need an Arduino Uno board (or compatible board), an LED of any colour, a 470-Ohm resistor, two jumper wires, a breadboard, a male A-B USB cable, and a computer (Mac/Windows) with the Arduino IDE software installed.

This project involves programming your Arduino Uno to make an LED light blink on and off. To get started, watch the video below or click here to view it on YouTube. Access the links below to get a copy of the code, printed instructions, schematic, and a guide to resistors.

Downloads:

The source code is also available here:

/*
 Blink
 Turns on an LED on for one second, then off for one second, repeatedly.
*/
 
// Give the LED a name - it will be connected on PIN 13
int led = 13;
 
// the setup routine runs once when you press reset:
void setup() { 
 // initialize the digital pin as an output.
 pinMode(led, OUTPUT); 
}
 
// the loop routine runs over and over again forever:
void loop() {
 digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
 delay(1000); // wait for a second (1000 = 1 sec.)
 digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
 delay(1000); // wait for a second
}

Photos

1 2 3 4

Getting started with Python

Welcome to the first Python 3.3 tutorial. Python is a language that is used in a wide range of applications including web-based apps, desktop applications, mobile applications, and games. Python is cross-platform meaning it can be used to code on and for a number of platforms including Windows, Mac and Linux.

Python is a clean, easy-to-read language that is great for beginners to learn. If you’ve never done any programming before then Python is a nice choice.

This video tutorial explains how to use the Python IDE and shell, and how to create your very first program in the Python programming language. View the video below or click here to watch it on YouTube.