Introduction: Mho PlayGround Circuit Scribe

About: Fundador de The Inventor's House Hackerspace, Movimiento Maker y Hardware Libre, DIY, Workaholic

Siempre he querido jugar el juego de Adafruit Industries de "Mho Playground" pero solo esta para iOs y yo tengo Android, así que decidí hacer mi propia versión en el mundo real, les presento "Mho Playground Circuit Scribe" Beta, con arduino UNO, processing y circuit scribe, realizado en la #BuildNight de Febrero de The Inventor House por Meño y Sabas.

Esperamos les guste

Step 1: Material

El material y software necesario para realizar este instructable es:
  • Circuit Scribe Kit Basic
    • 1 Modulo Bi-Led
    • 4 Modulo Adapter
    • Tinta conductiva
    • 5 Modulo Cable connector
  • Arduino Uno
  • Laptop
  • Hoja de Papel
  • 3 Resistencias
    • 100 ohms
    • 1K
    • 4.7K
  • Papel
  • Impresora
  • Processing (https://processing.org/download/)
  • Arduino IDE

Step 2: Programacion

Lo primero que realizaremos es la programación de nuestro arduino UNO, al final de este paso dejamos el link de los sketchs para su descarga

CÓDIGO ARDUINO: (Meño)

//Se declaran todas las variables que se utilizaran.

char A;

int d;

float a,c;

int b;

void setup(){

//Se inicializará el monitor serial.

Serial.begin(9600);

//Se declaran los pines 12 y 13 como salida para prender y apagar bi led.

pinMode(12, OUTPUT);

pinMode(13, OUTPUT);

void loop (){

//Se valida si hay algo en en monitor serial.

if (Serial.available()>0) { 

//Se guarda en la variable el contenido que se este enviando desde el monitor serial.

 A=Serial.read();

//Se valida el contenido de la variable. 

if (A=='A'){

 //Se lee el valor que se obtiene del pin analógico 0.  

a=analogRead(0);

//Se realiza una regla de 3 y algunos cálculos aritméticos.

c=float (a*5/1024); 

b=float(1000*(5-c)/c);

//Se utiliza para DEPURACIÓN.

//Serial.println(b);//Se valida el valor obtenido de los cálculos aritméticos con los rangos aproximados que tiene cada una de las resistencias.

//#RESISTENCIA 1K 

if (b>1500 &&  b<2100)            

{
          Serial.println(110);            } 

//#RESISTENCIA 4.7 K  

if (b>5200 &&  b<7200)            

{            Serial.println(470);             

} 

//#RESISTENCIA 100 OHMS 

if (b>800 &&  b<1100)            

{            

Serial.println(100);             

}

delay(1000);  

}

if (A=='D'){  

digitalWrite(13,LOW);   

digitalWrite(12,LOW); 

}<br> if (A=='B'){   

digitalWrite(13,LOW);   

digitalWrite(12,HIGH); 

} 

if (A=='C'){ 

digitalWrite(12,LOW);   

digitalWrite(13,HIGH); 

}

}


Ahora debemos empezar con la parte gráfica de nuestro juego en esta ocasión he elegido hacerlo con Processing debido a que se pueden realizar prototipos muy rápido y debido al poco tiempo que tenemos en la BuildNigh es perfecto para reflejar lo que queremos realizar.

Lo primero que debemos hacer es descargar unas cuantas capturas de pantalla del videojuego original Mho PlayGround que podemos encontrar en Google. Con Inkscape o algún otro editor de imágenes podemos editar las imágenes para borrar el marcador de tiempo y valor de resistencia y colocar los nuestros.

Después de eso ahora debemos poner todo en processing

El código en processing es el siguiente:

//Mho PlayGround Circuit Scribe

//Bajo una Licencia Creative Commons 4.0

//Andres Sabas Enero 2015

//BuildNight Instrutable

PImage screen;

PImage gameover;

PImage win;

PImage play;

boolean start00 = false;

boolean control = false;

int score, valor;

float tiempo;

color colorVerde = color (0, 255, 0);;

color colorAzul=color(0,0,255);;

String value;

PFont font;

int time;

String timeString = "20", item;

int initialTime, m;

int interval = 1000;

int totalTime = 22000;

StringList resistencias;

StringList resistencias2;

int index;

import processing.serial.*;

Serial mySerial;

void setup()

{size(320, 568);

resistencias = new StringList();

resistencias.append("100");

resistencias.append("1000");

resistencias.append("4700");

resistencias2 = new StringList();

resistencias2.append("100");

resistencias2.append("110");

resistencias2.append("470");

background(0);                          // black background

screen = loadImage("mho.png");

gameover = loadImage("error.png");

win = loadImage("mhowin.png");

play = loadImage("mhoplay.png");

//start1 = loadFont("Bim.ttf");

 start00 = true;

 control = true;

 fill(0);

 mySerial = new Serial( this, "COM14", 9600 );

 mySerial.buffer(3);

 mySerial.write(68); // Print "D"

}

void draw()

{

  if (start00 == true) { 

    image(screen, 0, 0);

     fill(0, 90, 90);

     textSize(32);

     text("Circuit Scribe", width * 0.15, height * 0.36);

     fill(0, 90, 190);

     textSize(22);

     text("start", width * 0.4, height * 0.41);

     textSize(14);

     text("Diseñado por Sabas y Meño", width * 0.2, height * 0.48); 

     text("The Inventor's House", width * 0.2, height * 0.51);

     textSize(22);<br>     text("Build Night Circuit Scribe", width * 0.1, height * 0.59);

     index = int (random(3));

  }

  if(start00 ==false && control == true){

    m=millis()-initialTime;

    background(play); 

      if (millis() - m > interval)

      {

        time = int(21-(millis()/1000));

        timeString = nf(time, 2);

        m = millis();

      }

    fill(colorAzul);

    item = resistencias.get(index);

    text(item, width * 0.4, height * 0.13);

    fill(colorVerde);

    textSize(30);

    text(timeString + " sec", width * 0.8, height * 0.13);

    if (millis() > totalTime)

      {

        mySerial.write(65); // Print "A"

         control = false;

       }    

  }  

}

void mousePressed() {

  if (start00 == true && (mouseX > ((width * 0.4) - 200)) && (mouseX < ((width * 0.4) + 200)) && (mouseY > ((height * 0.35)-40 ) && (mouseY < ((height * 0.35) + 40)))) {

    initialTime = millis();

    start00 = false;

  }

}

void serialEvent(Serial port) {


// Data from the Serial port is read in serialEvent() using the read() function and assigned to the global variable: val

  value = mySerial.readString();

  item = resistencias2.get(index);

  // For debugging<br>  println( "Raw Input:" + value);

  println( "Valor resistencias:" + item);

      if (value.equals(item)){

       background(win);

       mySerial.write(66);

    }

     else{

      background(gameover); 

      mySerial.write(67);

     }

}

Puedes descargar las imágenes y código desde el siguiente link: archivos arduino y processing

Step 3: Armado

Lo primero que debemos realizar es nuestro circuito en 123d.circuits.io donde podremos simular nuestro circuito, en esta caso yo no encontré la manera de simular un arduino y ademas poder importar una imagen de Mho, pero lo hice a mano con las herramientas que proporciona Circuit Scribe

123d.circuits.io/circuits/586843-mho-playground-circuit-scribe

Las resistencias que se ven en el circuito son de 100, 1K y 4.7K y deben montarse sobre

Ahora debemos imprimir la imagen de Mho Resistor que mas nos guste y empezar a hacer trazos como se muestra en la imágenes y circuito anterior, como se pudieron dar cuenta es un simple divisor de voltaje con el que determinamos el valor de la resitencia

Step 4: Jugar

Ahora es momento de ejecutar nuestro sketch en Processing y empezar a jugar



El led azul indica que la resistencia colocada es la correcta y el led rojo que la resistencia colocada es la incorrecta.

NOTA: Considere que este proyecto se realizo en menos de 4 horas en una BuildNight entonces tendrá algunos bugs.

Saludos y hasta luego inventores :D




Explore Science Contest

Participated in the
Explore Science Contest