I/O Experiments

From MigWiki
Jump to: navigation, search



Your Mignon Game Kit is compatible to the Arduino I/O board. The main difference is that most of the micro-controller pins are used to drive dot-matrix-display, speaker, and the buttons. But some of the pins are left over! With this pins you can start very exciting input / output experiments.

The EXTENSIONS port matches (top down) the Arduino pins digital 5, GND, +5V, Analogin 5, and digital 7. Below you find the eyelet of digital pin 6.

You find a comprehensive collection of examples and how-tos on the Arduino home page [1].

Blinking LED[edit]

One would plug the long leg (+) of a LED to the first digital pin 5. Accordingly the short leg (-) should be connected to a series resistor ca. 220 Ohm and the other end of the resistor to GND. You need the series resistor to avoid the a fusing of the LED.

Now you can run you LED blinking with the following code:

int ledPin =  5;                // LED connected to digital pin 5
void setup()   {                
 pinMode(ledPin, OUTPUT);      // initialize the digital pin as an output

void loop()                     
 digitalWrite(ledPin, HIGH);   // set the LED on
 delay(1000);                  // wait for a second
 digitalWrite(ledPin, LOW);    // set the LED off
 delay(1000);                  // wait for a second

Sensor Read Send[edit]

With his code you can read a electric currents between 0 and 5 V. The forth pin of the EXTENSION port "pin 19 / adc 5" is the sensor pin. "adc" means analog / digital converter and is compatible to "Analogin" on the Arduino board. If you connect a sensor such as a photo cell you can control the speed of the blinking LED with light. And via MigProg this example sends numeric values to your computer. One can use this stream for instance with a processing application [2].

int sensorPin = 5;                      // select the input pin for the potentiometer
int ledPin = 5;                         // select the pin for the LED
int sensorValue = 0;                    // variable to store the value coming from the sensor

void setup() {
  pinMode(ledPin, OUTPUT);              // declare the ledPin as an OUTPUT
  Serial.begin(9600);                   // open the serial port at 9600 bps

void loop() {
  sensorValue = analogRead(sensorPin);  // read the value from the sensor
  digitalWrite(ledPin, HIGH);           // turn the ledPin on
  delay(sensorValue);                   // stop the program for <sensorValue> milliseconds
  digitalWrite(ledPin, LOW);            // turn the ledPin off
  delay(sensorValue);                   // stop the program for for <sensorValue> milliseconds
  Serial.println(sensorValue);          // print it out to the serial port

Control RGB LED[edit]

by Sebastian Sester



#include <avr/pgmspace.h>
int k=0;
void setup(){
  // Initialise the pins
  pinMode(5, OUTPUT); 
  pinMode(6, OUTPUT); 
  pinMode(7, OUTPUT);

void loop(){
  // Reset pins
  digitalWrite(5, LOW);
  digitalWrite(6, LOW);
  digitalWrite(7, LOW);
  // Read input
  k = analogRead(5) / 100;

  // Decide which pins should be activated
  if((k >= 0 && k < 4) || k >= 10)
    digitalWrite(5, HIGH);
  if((k >= 2 && k < 7) || k >= 10)
    digitalWrite(6, HIGH);
  if(k >= 6)
    digitalWrite(7, HIGH);
  if((k > 8 && k < 10) || k >= 10) {
    digitalWrite(5, HIGH);
  // wait & start again


You could also control a LCD with the MGK: LCD-Extension