Cricket (Handy Cricket)

  • View

  • Download

Embed Size (px)


Cricket (Handy Cricket). Kyeongseo Hwang (Mike) Nicholas Ver Hoeve. Agenda. About Cricket (HW) History of Logo (Built in interpreter) Intro to Cricket Logo Demo. About Cricket. LIGHT SENSOR. TOUCH SENSOR. MAG. REED SWITCH. IR SENSOR. DC MOTOR. BREAK BEAM SENSOR. History of Logo. - PowerPoint PPT Presentation

Text of Cricket (Handy Cricket)

  • Cricket (Handy Cricket)Kyeongseo Hwang (Mike)Nicholas Ver Hoeve

  • AgendaAbout Cricket (HW)History of Logo (Built in interpreter)Intro to Cricket LogoDemo


  • History of LogoLogo: Developed in BBN (a Cambridge University research firm), in 1966By Seymour Papert, Wally FeurzeigModeled after LISPNow in multiple dialects; ExperLogo, ARLogo, MIT StarLogo, NetLogo, etc.Cricket Logo developed in MIT by Brian Silverman with Fred Martin beginning in 1995

  • Intro to Cricket LogoProcedure definition with inputs and return valuesGlobal variables and local procedure inputsControl structures: if, repeat, and loop16-bit number system: addition, subtraction, multiplication, division, remainder, comparison, bit-wise operations, random functionMotor and sensor primitivesTiming functions and tone-playing functionsData recording and playback primitivesIR Communications primitives

  • Intro to Cricket Logo

  • Motor Commanda,Motor Ab,Motor Bab,Motor A and Bon Selected motor Onoff Selected motor Offonfor # Selected motor will turn on for #/10 secs.thisway/ thatwaySets directionrd Reverses the directionsetpower # set power level

  • Sensor Commandswitcha return 1 if switched plugged into sensor A is pressedswitchb return 1 if switched plugged into sensor A is pressedsensoraReport the value of sensor A 0~255sensorbReport the value of sensor B 0~255

  • Timing and tone-playingTimingab, on wait 20 offab, onfor 20wait #timerresettTone-playingbeepnote 110

  • Control Structuresrepeat times [body]loop [body]if condition [body]ifelse condition [body-1] [body-2]waituntil [condition]stop(!)output returning_value

  • Numbers16 bit number system-32768 ~ +32767All arithmetic operators separated by a space 3 + 4Normal expression precedence rules are not used, evaluated left to right 3 + 5 * 7 = ?(3 + (4 * 5)) = ?

  • Number Operator (cont)+ Infix addition- Infix subtraction* Infix multiplication / Infix division% Infix modulus (remainder after integer division). < Infix LESS-THAN test. Results in 1 if left-hand value is less than right-hand value; 0 otherwise.

  • Number Operator (cont)> Infix GREATER-THAN test. Results in 1 if left-hand value is greater-than than right-hand value; 0 otherwise. = Infix equality test. Results in 1 if left-hand value is equal to right-hand value; 0 otherwise. and Infix AND operation (bitwise). or Infix OR operation (bitwise). xor Infix exclusive-OR operation (bitwise). not prefix NOT operation (logical inversion, not bitwise). random Reports pseudo-random number from 0 to 32767. Use the modulus operator to reduce the range; e.g., (random % 100) yields a number from 0 to 99.

  • Procedure Definition with inputto flash1 repeat 10 [a, onfor 5 wait 5] end

    to flash2 :n repeat :n [a, onfor 5 wait 5] end

    global [temp] to detect settemp sensora if temp < 30 [output 1] if temp < 50 [output 2] output 3 end

  • VariablesGlobal variableglobal [variable-list] e.g. global [cat dog]Stored in RAM -> data recording and playback functionsInteger onlyGlobal-setting primitivesetcar, setdog e.g. setcat 3 setcat cat + 1Global Arrayarray [clicks 10 clacks 15] Array indices start at 0 aget name indexaset name indexNo buffer-overrun checkingStored consecutively in memorystored in the Cricket's non-volatile memory

  • Data Recording and Playbackto take-data resetdp repeat 2500 [record sensora wait 10] end resetdpsetdp positionerase #record valueRecall

  • Recursionto fact :n if :n = 1 [output 1] output n * fact :n 1 end -> repeat fact 3 [beep wait 1]

    Normal Recursion has uncertain max depth, can be as low as 5Supports Tail Recursionconverting the recursive call into a goto statementto beep-forever beep wait 1 beep-forever end

  • Multi-Taskingsupports a limited form of multi-taskingOne background taskrepeatedly checks a conditionWhen true it interrupts and processes when [switcha] [beep] loop [a, onfor 5 rd] only one background task operating at any given time.If a when statement is executed after the background task has already been started, the subsequent when task supercedes the earlier oneTo stop the background task from operating, use the primitive whenoff.

  • SamplesFiles at the multi-takingIR communication between cricketsBackground Operation


    Microchip PIC microprocessor with built in logo interpreter 4096 bytes for programs and data memory Motor ports with LED indicators used for motors, lamps Sensor ports used for sensors like touch switches, light sensors Bus ports for special Bus Devices (LED number display) Beeper can be programmed to play notes IR transmitter- communicates with other crickets and PC interface Everything comes unassembled so you get to solder!