Get in contact

posts/page

Clap Back Robot – Damien Kee

Jun 23, 2008

This robot samples any loud sounds and keeps track of the time between each. It then plays back the rhythm by tapping on a plastic container. The code is written in NXC and is a good example of how arrays can be used.

task main(){
int time[20]; //Take a maximum of 20 samples
long t0;
int i=0;
int x=1;
SetSensorSound(IN_1); /* Setup port 1 as sound sensor */
t0 = CurrentTick();/* Grab the current reading of the timer */

/* Loop while the difference between the current timer and the initial timer is less than 5 seconds */
while ((CurrentTick()-t0) < 5000) {
  if(Sensor(IN_1) < 30) {   /* If the sensors hears a loud sound, record the timer value */
    time[i] = CurrentTick()-t0;
    i++;
until(Sensor(IN_1) < 29); /* Wait until that sound has dissapated before looking for the next */
}

}

/* Start taps */
OnFwd(OUT_A, 100); Wait(75);
OnRev(OUT_A, 100); Wait(75);
Off(OUT_A);
for(x=1;x<20;x++) {
  if(time[x]==0){   /* If the difference is 0, that means that there are no more claps recorded */
  break;
}

/* Wait for the time difference between each clap don’t forget that tap also takes up a certain amount of time */
Wait( time[x]-time[x-1]-150);
OnFwd(OUT_A, 100);  Wait(75);
OnRev(OUT_A, 100); Wait(75);
Off(OUT_A);
}

Wait(1000);

}

Get in Contact

  • Brenda Gahan - Head of Learning image

    Brenda Gahan - Head of Learning

    Sunshine Coast Grammar School
    star star star star star

    His wealth of knowledge and expertise allows him to tailor each workshop to the specific skill level and interests of the students (and teachers) and ensures that everyone is engaged and challenged.

  • Digital Technologies Teacher image

    Digital Technologies Teacher

    Victoria Point State High School
    star star star star star

    Students engaged in hands-on learning experiences that developed their problem-solving skills. It was a valuable and highly relevant real world learning opportunity.

  • Tammy Grady image

    Tammy Grady

    Senior Project Officer, QMEA
    star star star star star

    Through the Queensland Minerals and Energy Academy (QMEA), Damien has worked with hundreds of students and Teachers from across the State, all with varying levels of robotic and programming experience. Feedback from Damien’s workshops are always full of praise and appreciation, not only for his professional knowledge, but his adaptable teaching style and ease of delivery.

  • STEM Teacher - Years 7-10 image

    STEM Teacher - Years 7-10

    Tannum Sands State High School
    star star star star star

    Damien's professionalism and communications skills are superb. The very best educational expert visitor we have had come to the college.

  • Primary School Teacher - Year 5 image

    Primary School Teacher - Year 5

    Central Queensland Primary School
    star star star star star

    Damien's delivery style captivated students across every year level, from junior to senior. His depth of knowledge and genuine ability to tailor content to our students' abilities made a real difference, keeping everyone engaged and getting the most out of the experience regardless of their starting point.

  • Head of Curriculum image

    Head of Curriculum

    South East QLD Primary School
    star star star star star

    What stood out most was how thoroughly Damien customised the workshop to our school's specific needs. Rather than a one-size-fits-all session, he took the time to understand what we were after and delivered exactly that.