Build a Ball- Counting Robot by Makeblock and Lego (complete instruction on May 25)


#1

The complete instruction is published on Makezine.com

http://makezine.com/projects/build-a-ball-counting-robot-using-makeblock-and-lego/

Here is the program,

#include <Makeblock.h>
#include <Arduino.h>
#include <SoftwareSerial.h>
#include <Wire.h>

MeServo servoDriver(PORT_3,DEV1);
MeDCMotor motor1(M1);
MeDCMotor motor2(M2);
MeLimitSwitch limitSwitch(PORT_6);
MeNumericDisplay disp(PORT_5);

uint8_t pos1=90;
uint8_t pos2=0;
uint8_t motorspeed = 100;
uint8_t flag;
uint16_t num=0;
unsigned long time1;
unsigned long time2;

void setup()
{
  servoDriver.begin();
  servoDriver.write(pos1); 
  disp.display(num);
  Serial.begin(9600);
}

void loop()
{
    motor();
    motor1.run(100);
    motor2.run(motorspeed-82);
    check();

}

void motor()
{
    time1 = millis();
    while(millis()-time1<700)
    {
      servoDriver.write(pos2); 
      check();     
    }
    time2 = millis();
    while(millis()-time2<3000)
    {
      servoDriver.write(pos1);
      check(); 
    }
}

void check()
{
    if (!limitSwitch.touched())
    {   
        motor2.stop();
        motor1.stop();
        servoDriver.write(pos1); 
        num+=1;
        disp.display(num);  
        buzzerOn();
        delay(300);
        buzzerOff();
        delay(1000);
        while(!limitSwitch.touched());
        motor2.run(motorspeed-82);
    }
}

#2

Hi. Some sort of reference to what this code is for would be nice. :smile:


#3

Sounds like a fun challenge!
I hope to find the time to do this before May 25th.

paul


#4

Hi @tormodhau

I have upload the instruction on Makezine.com, there is a robotic week around the May 25. So the editor would like to publish it on May 25. So I think maybe it’s not appropriate to publish it here first. But you can find the video on Youtube,


#5

Thanks! I will copy the link of instruction here on May 25. You can get the video now.


#6

Hi @paulcobbaut and @tormodhau,

The complete instruction is published on Makezine.com

http://makezine.com/projects/build-a-ball-counting-robot-using-makeblock-and-lego/