Microduino MIXC104E KIT-mCookie-Education User Manual Part 1

Microduino Inc. KIT-mCookie-Education Part 1

Contents

User Manual Part 1

1
2Table Of ContentsScratch IntroductionHardware IntroductionRotating Motor Project Motion Sensor Motor ProjectEmoji Robot ProjectSingle Axis Steadicam ProjectAirbag ProjectWired RC car ProjectSafety Car ProjectDelivery Truck ProjectObstacle Course ProjectEdge Avoidance Car ProjectLine Finding Car 1 ProjectLine Finding Car 2 Project3-2526-4647-6869-8889-108109-127128-147148-167168-187188-208209-229230-250251-271272-294A Guide Book For MIXC104E
3With Scratch, you can program your own interactive stories, games, and animations — and share your creations with others in the online community.Scratch helps young people learn to think creatively, reason systematically, and work collaboratively — essential skills for life in the 21st century.Your students can use Scratch to code their own interactive stories, animations, and games. In the process, they learn to think creatively, reason systematically, and work collaboratively — essential skills for everyone in today’s society.
4IntroductionThe Microduino MIX guide will show guide will walk you through an introduction in the use of Arduino’s Scratch editor and then a number of projects. With each project the challenge level increases so as to expand your knowledge of coding and code thinking.The process of coding also involves how to organize in your thinking the process and sequence of events that will result in the correct oper-ation of your project.In our projects we use the Arduino ‘Scratch’ editor to construct and ex-ecute code to drive the hardware of projects. Scratch has become one of, if not the, most popular coding tool today.As you read the introduction of Scratch keep in mind that the basic ar-eas of the scratch editor uses many similar terms used in the parts of a stage play. It refers to stages, scripts, costumes, backdrops and so on. This is meant to help us create a mental image of what we doing. Beyond this we get into the more technologial terms of technology.
5Installation
6The InterfaceToolbarScripts AreaPalettes & PanesSprites & BackdropStage
7ToolbarThe Tool Bar in Scratch provides many useful functions and conguration options. Below is a quick overview of each menu item. Some terms and phrases will be explain later.New Project - creates a new blank project.Open Project - open a saved project.Save / Save As - save / save as the current project.Undo - undo the most recent change in the project.Redo - redo the most recent undo in the project.Settings - various conguration settings for Scratch.•  Kit - select a Microduino kit, which shows enables dierent blocks.•  Flash rmware - ash the required rmware onto the hardware to use Scratch / Live mode.•  Language - select language.•  Check update - check for and update to the latest Scratch version.•  Issue report - submit a bug report.•  About - information on the version of Scratch.Mode Selection - select dierent control modes for Scratch:•  Scratch / Live mode - control MIX hardware in real time using Scratch blocks. MIX hardware requires a constant connection to a PC in order to function.•  Arduino Mode - compiles and uploads codes onto MIX hardware. Once a program is uploaded, MIX hardware can run independently without a PC connection.•  Text Coding Mode - text based programming. Currently under development. Serial Port - select serial port for usage or program-ming of MIX hardware.
8StageScratch can be thought as a school play. The Stage is where the viewer sees the play. Sprites can be thought as actors or characters in a play. Backdrop is the background. Together they make the Stage. Below is a quick overview. Some terms and phrases will be explained later.Stop Sign:When clicked, stops all Scripts that are running.Green Flag:When clicked, all “When Green Flag Click” blocks activates.Backdrop:Is the background of the stage. There can only be one Backdrop. It can be change and you can also design your own.Sprite:Sprites can be thought as actors or characters. There can be multi-ple Sprites on the Stage. You can also design your own.The Stage includes Sprite(s) and a Backdrop.
9Sprites & BackdropThis section allows you to select, edit and create Sprites and Backdrops. Select-ing a Sprite or Backdrop is done by clicking on it from this section. Below is a quick overview. Some terms and phrases will be explained later.Sprites in your project are located here. There can be multiple sprites in a project. New projects automatically have one Sprite included. Its name is Corey.Add a new sprite from the sprite library.Add a new backdrop from the backdrop library.Current backdrop.When a sprite is selected. Edit the sprite name, sprite position on the stage, visibility, size of the sprite and the angle of the sprite.
10Palettes & PanesThis section of the interface contains the Sprite Pane, Costume Pane / Backdrop Pane, and Sound Pane. You can switch between the panes by clicking on the appropiate tabs.Click to activate Script pane.Click to activate Costumes or Backdrops Pane.Click to activate Sound pane.
11Script PaneThe Script Pane contains the tools you need to make your Sprite or Backdrop do things. A Script can be thought of as the instructions that your Sprite or Back-drop follows, similar to a school plays’ script which instructs the actor what to do. Some terms and phrases will be explained later.Block Categories:Blocks are sorted to dierent categories for quicker access. Each category has its own color and the Blocks contained within are the same color. For example, “Motion” Blocks are all purple.Blocks:Blocks are instructions for your Sprite or Backdrop to follow. There are many Blocks each with their own type. Blocks are cate-gorized into dierent categories.
12Scripts AreaThe Scripts Area is one of the most important parts of the Scratch interface. It allows you to create and assemble the Script for your currently selected Sprite or Backdrop. You can drag Blocks from the Scripts Pane into the Scripts Area to assemble your Script. Each Sprite or Backdrop has its own personal Scripts Area. A Script can be thought of as the in-structions that your Sprite or Backdrop follows.Scripts Area:Assemble your Script for your currently selected Sprite or Backdrop.Assemble Scripts by dragging Blocks into the Script Area.
13Exercise: “First Steps” Block LocatorLet’s create your very rst project! Let make Corey take its very rst steps.Assemble the Script below by dragging the Blocks you need from the Sprite Pane into the Scripts Area. The “Block Locator” sidebar is there to aid you in nding the blocks you need you need quickly. Use it for your convenience!Assemble Scripts by dragging Blocks into the Script Area.Motion
14Exercise: “First Steps”Now click on the Block you just added to the Scripts Area. What happens toCorey on the stage? It moved 10 steps to the right!Click on any colored partof the block to activate it.
15Types of BlocksThere are dierent types of Blocks which have dierent shapes. Each shape has a dierent purpose and is intended to aid in assembling Scripts.Hat blocks are the blocks that start every script. They are shaped with a rounded top and a bump at the bottom — this is so you can only place blocks below them.Stack blocks are the blocks that perform the main commands. They are shaped with a notch at the top and a bump on the bottom — this is so blocks can be placed above and below them.Boolean blocks are the conditions — they are either true or false. It’s like asking your friend: “Does 2 + 2 = 4?”, and they would either tell you “Yes” or “No”. Boolean blocks have a hexagonal shape.Reporter blocks are the values. Shaped with rounded edges, Reporter blocks can hold numbers and strings. It is like asking a friend, for example, “What is 2 + 2?”, and they would answer “4”. It is not just equations however, it can report a variable, for example, “What is your age?”. They may answer: “15”. C blocks are blocks that take the shape of “C’s”. Also known as “Wrap blocks”, these blocks loop the blocks within the Cs or check if a condition is true.Cap blocks are the blocks that end scripts. They are shaped with a notch at the top and a at bottom — this is so you cannot place any blocks below them.Source: https://wiki.scratch.mit.edu/wiki/Blocks
16Costume PaneWhen a Sprite is currently selected, the middle tab becomes the Costume Pane. This section allows you to design Costumes for your currently selected Sprite. Costumes can be thought of as a dierent image / appearance for your Sprite. It is useful to use Costumes when creating animations for your Sprite or if you want your Sprite to change its appearance.When a Sprite is selected.Add a new costume for the currently select-ed Sprite.Costumes for the currently selected Sprite.Editing tools.Costume’s name.Costume’s Appearance
17Exercise: “Second Steps” Block LocatorHow can we animate Corey to look like it is walking?We change Corey’s costume to look like it is taking steps.Assemble the Script below:MotionLooksControl
18Click on any color portion of the Script. What does Corey do?Corey walks with an animation! Click repeatedly to make Corey perform the animation over and over again.Click on any colored partof the block to activate it.Exercise: “Second Steps”
19When Backdrop is currently selected, the middle tab becomes the Backdrops Pane. This section allows you to design Backdrops. It is useful to have multiple Backdrops if you want to change the background for your project.When a Back-drop is selected.Add a new Backdrop to the project.Backdrops in the current project.Editing tools.Backdrop’s name.Backdrop’s AppearanceBackdrop Pane
20Corey doesn’t like walking in a blank white space. Corey wants to walk in the park!How can we make Corey walk in a park?We can change the Backdrop to a scenery of a park.But rst we need to create a Backdrop of a park.Creating a BackdropAdd a new backdrop from the backdrop library.
21Creating a BackdropSelect a backdrop for the park.
22Exercise: “A Walk in the Park” Block LocatorDon’t forget to switch back to Corey by selecting Corey and then switching to the Scripts Pane.Once you have created your new Backdrop, assemble the blocks below:MotionLooksControl1. Click to select Corey.2. Click to switch to Switch Pane.Set to your newly Created Backdrop.
23Exercise: “A Walk in the Park”Click and Corey will start walking forever.Click to change the Backdrop to the default white one.Click to change the Backdrop to your custom one.
24Sound PaneList of sounds for the currently selected Sprite or Backdrop.New sound creating options.Click to activate Sound pane. Sound’s name.Editing and playback tools.Sound wave appearance.
25This chapter is intended to give a basic understanding of how to use Scratch when creating projects inthe MIX kits. There are a vast amount of topics to learn about Scratch which are outside the scope ofthis product. Many resources can be found online to learn more about Scratch!Further LearningLinks•  https://scratch.mit.edu/
26Hardware Mix 4
27MIX 4 Kit Contents1x Color LED1x Touch Button1x USB Cable 24x Hub Connector CablesSensors Trinkets4x Line Finder2x Servo2x Potentiometer1x Motion1x Motor Controller2x IO Splitter1x Remote Control1x IR Receiver2x Wheel2x MotorBuilding Blocks1x mCenter+1x OLED1x Servo Connector1x Joystick1x Buzzer
28Scratch and mCookieThe Microduino version of Scratch contains special added features which enables the use of mCookie modules. The Blocks under the Category Block called Arduino and mCookie, adds support to use mCookie modules.Blocks can be found under the category Arduino and mCookie.
29Scratch and mCookieYou can use the Blocks under the Arduino and mCookie category in your Scripts as you would use any other Block.Arduino and mCookie Blocks.
30mCookie SeriesMicroduino’s mCookie series is designed for ease of use. The series is modular, stackable, magnetized, easily connect-able and building blocks compatible. It makes assembling a project quick and easy.Modular Stackable and Magnetized Building Block Compatible
31mCenter+Is a ve-in-one module which contains:•  Li-ion Battery: battery pack to power your projects which can be recharged via the USB port.•  mCookie Core+: a tiny central processing unit (CPU), which is the brains of your projects.•  USB Programmer: programs the Core+ module and acts as a serial communication bridge between your computer and Core+ module.•  Bluetooth Upload: similar to the USB programmer, but works wirelessly over Bluetooth communication.•  Hub: connects various modules such as sensors, trinkets, and other modules to your projects. These modules can then be accessed by the Core+ module.MicroUSB Port: To charge the battery and upload programs to a embedded Core+ module when connected to a computer.IMPORTANT: When uploading programs, make sure the red LED is on, which means the modules are receiving power.Power Switch: Turn on or o the battery to supply power to the modules.LED Power Indicator: Indicates if mCenter is on or o.Hub Connectors: Connect sensors or trinkets to mCenter+ with a Hub Connector Cable.Module Pad: Stack modules to mCenter+.
32Embedded Core+ ModulemCenter+ contains an embedded Core+ module. The Core+ module is the brains of your projects. It is a tiny central pro-cessing unit (CPU) that you can program or control. It is capable of controlling or sensing information from other modules. It is programmable when connected to a computer.
33mCenter+’s HubmCenter+ incorporates a Hub. The Hub connects various modules such as sensors, trinkets, and other modules to a project. These modules can then be accessed by the embedded Core+ module. The Hub has 10 connection header ports. Each connection header has support for dierent sets of features. Some headers may support a feature, while another may not.2/3 6/78/9I2C A2/A3I2CI2C4/5A6/A7A0/A1I2CI2CI2CA6/A7A2/A3A0/A12/3 6/74/5 8/9Digital signals produce only a o (LOW) or on (HIGH) state. There is no “middle” state between the two.Analog signals are continuous and fea-ture many “middle” points. They look like smooth curves.IIC is a type of serial communication interface. It is more ad-vanced than digital and analog signals. Under IIC, messages are exchanged and understood between communicating mod-ules. Modules such as the OLED screen, temperature & humid-ity sensor, real time clock (RTC) module and other modules use this method of communication.
34Color LEDThe Color LED is a LED composed of 3 smaller LEDs which emit red, green, and blue. Each color’s brightness value can be congured individually. This can produce a wide variety of colors. It is controlled over a special communication protocol which is dier-ent from the basic “Digital Output” (used by Single-Color LED).UsageThis block congures what color a particular Color LED displays.Hub pin the 1st Color LED is connected.Transition fromthis color.Transition tothis color.Color LED - Color Select blockColor LED - Color Transition blockThis block causes a particular Color LED to transition from one color to another color under a time span. (Note: This block must complete its transition before proceeding to the next block in the script.)Index of the Color LED to congure.Color to changethe Color LED to.Hub pin the 1st Color LED is connected.Set duration (in milliseconds)for the transition.•  The Color LED connected directly to the Hub is index 0.•  The Color LED connected next in the chain is index 1.•  And so on.Indexing2/38/9I2C A2/A3I2CI2C4/5A6/A7A0/A16/7IN INOUT OUTIndex of the Color LED to congure.ColorLEDIndex: 0ColorLEDIndex: 1
35A Potentiometer is a input module which can be turned or rotated right or left. Based on the position of the knob, it produces a dierent signal value for the Core module to read. It must be connected to an analog port (ports denoted with “A”).Analog Read blockThis block returns the value from the Potentiometer. A value between 0 and 1023 is returned. If the potentiometer is turned all the way to the left, it produces a 0 value. If it is turned all the way tot the right, it produces a 1023 value. In the middle it produces a value around 512.Pin the Potentiometer is connected to.0 1023Potentiometer
36MotorA Motor is a electrical machine which converts electrical energy to mechanical energy. It is capable of rotating clockwise and counter clockwise. It is controlled by a Motor Con-troller. A Motor Controller can control up to 2 Motors. A Wheel can be attached to the Motor.Motor Controller WheelMotor - Set Speed blockThis block sets the speed of the motor. Positive values turns the Motor in one direc-tion. While negative values turns the Motor in the opposite direction. A value of 0 stops the Motor. Values between -255 and 255 are accepted. 255 is maximum clock-wise speed. -255 is maximum counter-clockwise speed.Motor - Brake blockThis block sets the speed to 0 to stop the Motor.Motor to congure.Motor to congure.Speed to set.
37MotionThe Motion module is a triple axis accelerometer and gyroscope.It is capable of measuring on the X, Y & Z axis the:•  Angle•  Acceleration•  Angular velocityIt uses the “I2C” communication protocol and must be connected to and “I2C” port on mCenter+.Motion - Read blockThis block reads data from the Motion module. It is capable of retrieving the angle, acceleration and angular velocity on the X, Y or Z axis.Angle, acceleration, or angular velocity to read.On the X, Y or Z axis.
38Servo - Set Angle blockServo - Move From-To Angle blockSets the angle of the Servo. Quickly moves (as fast as possible) to the desired angle.Sets the angle from the starting angle to the target angle. This move-ment is performed in the specied duration time.Pin the Servo is connected to.Angle to set Servo to.Pin the Servo is connected to. Starting angle of Servo.Target angle for Servo.Time in millisecond to move from starting angle to target angle.A Servo is an actuator which consist of a motor and other electronic components which allows for precise angle adjustments of the attached horn. The servo included in the kit has an adjustable angle range between 0 and 180 degrees.Servo
39A Joystick is an input module (sensor) which can sense if the stick is in the up, down, left or right positions.In addition, it can sense if it being pressed (pressing directly on stick).UpLeft RightDownPressUsageThe Joystick must be connected to an “Analog Read” compatible pin. These are the pins prexed with an “A” (pins A0 to A7).Joystick State blockOn the dened Joystick pin, if the stick’s position (up, down, left, right or center (pressed)) matches the state (released, pressed or pressing), then this block returns TRUE. Otherwise, this block returns FALSE.Pin Joystick is connected to.Stick position to check.Stick position’s state to match.Joystick
40The Line Finder module is able to detect reectivity or gray level of a surface. In gen-eral, darker or less reective surfaces produces a higher value. While a lighter or more reective surface produces a lower value. It must be connected to a pin with an “A” prex (A0/A1, A2/A3, A6/A7).Analog Read blockThis block returns the value that the Line Finder detects. A value between 0 and 1023 is returned.Pin that Line Finder is connected to.0 1023Darker, less reective surfaces.Lighter, more reective surfaces.Surface ReectivityValue ReturnedLine Finder
41Hardware ConnectivityStacking ModulesStacking module is done simply by stacking them on the mCenter+ or upon themselves as shown. Ensure pins line up correctly.Connecting Modules to the HubConnecting sensors, trinkets, and other modules to the Hub is done with the Hub Connector Cable. Connect one side of the cable to the module and the other to a port on the Hub. As shown.Stack modules,ensure gold pins align.Sensor, Trinket, or other moduleHub Connector CablemCenter+’s Hub
42Setup for ScratchUsing the mCookie modules with Scratch can be accomplished in two ways: Live mode and Arduino mode. The projects in this MIX Kit will use Scratch in Live mode. Arduino mode is an advanced mode and will not be covered in this Kit.Live Mode Arduino ModeSelect Live Mode here. Select Arduino Mode here.
43Live ModeLive Mode is the default mode when using Scratch. It allows you to use Scratch as normal, but with the ability to use mod-ules included in the MIX Kit. You must upload a special rmware onto the Core module to use this mode.In this mode, to control the modules, you will need to have your project connected to your computer sending commands in real time. If you disconnected the project from your computer, your project will no longer be receiving commands.Select Live Mode here.
44Live ModeA rmware is a program that runs on the Core module. Live Mode requires a special rmware to be upload onto the Core module. This special rmware allows the Core module to perform commands sent from your computer in real time. Uploading this special rmware only needs to be done once, unless it is overwritten with another rmware (such as when using Arduino mode).Computer send or receives commands with mCenter+ over USB.mCenter+ acts as a communi-cation bridge with the Comput-er and the embedded Core+ module.Core+ module receives or sends commands with mCenter+.
45Live ModeUploading the Special FirmwareIn Hardware•  Ensure drivers are install.•  Connect mCenter+ to your computer using a MicroUSB cable.•  A LED near the power switch should be on. If not, turn on mCenter+ with the power switch.In Scratch:•  Select the port mCenter+ is connected to.•  Select it again to disconnect. It should show “disconnected” before attempting to upload the rmware.•  Under Settings select Flash rmware and select mCookie to upload the special rmware. Uploading will start.•  Select the port mCenter+ is connected to again to begin using Scratch with MIX hardware.Select Serial Port. Flash rmware
46Arduino ModeArduino Mode is a special mode which can be enabled. It acts as a drag and drop editor for programming. The Stage is disabled and many Block Categories cannot be used. The main advantage of using Arduino Mode is that code is generated, compiled, and uploaded. This means that you can disconnect your project from your computer and it can still work. Whereas, during Live Mode, you need to have your project connected to your computer to instruct your project what to do. Arduino Mode can be accessed by clicking on the Arduino Mode button.mCenter+ runs its own program without needing to be connected to a Computer.Select Arduino Mode here.
47Revolutions IndicatorMIX4 - Project 1(Old Cards: MIX4A-01)
48About Revolutions Per Minutes (RPM)Revolutions per minute (abbreviated rpm, RPM, rev/min, r/min) is a measure of the frequency of rotation, specically the number of rotations around a xed axis in one minute. It is used as a measure of rotation-al speed of a mechanical component. Source: https://en.wikipedia.org/wiki/Revolutions_per_minute
49Review of ModulesmCenter+ Is a ve-in-one module which contains:•  Li-ion Battery: battery pack to power your projects which can be recharged via the USB port.•  mCookie Core+: a tiny central processing unit (CPU), which is the brains of your projects.•  USB Programmer: programs the Core+ module and acts as a serial communication bridge between your computer and Core+ module.•  Bluetooth Upload: similar to the USB programmer, but works wirelessly over Bluetooth communication.•  Hub: connects various modules such as sensors, trinkets, and other modules to your projects. These mod-ules can then be accessed by the Core+ module.
50Review of ModulesThe Color LED is a LED composed of 3 smaller LEDs which emit red, green, and blue. Each color’s brightness value can be congured individually. This can produce a wide variety of colors. It is controlled over a special communication protocol which is dier-ent from the basic “Digital Output” (used by Single-Color LED).UsageColor LEDThis block congures what color a particular Color LED displays.Hub pin the 1st Color LED is connected.Transition fromthis color.Transition tothis color.Color LED - Color Select blockColor LED - Color Transition blockThis block causes a particular Color LED to transition from one color to another color under a time span. (Note: This block must complete its transition before proceeding to the next block in the script.)Index of the Color LED to congure.Color to changethe Color LED to.Hub pin the 1st Color LED is connected.Set duration (in milliseconds)for the transition.•  The Color LED connected directly to the Hub is index 0.•  The Color LED connected next in the chain is index 1.•  And so on.Indexing2/38/9I2C A2/A3I2CI2C4/5A6/A7A0/A16/7IN INOUT OUTIndex of the Color LED to congure.ColorLEDIndex: 0ColorLEDIndex: 1
51Review of ModulesA Potentiometer is a input module which can be turned or rotated right or left. Based on the position of the knob, it produces a dierent signal value for the Core module to read. It must be connected to an analog port (ports denoted with “A”).Analog Read blockThis block returns the value from the Potentiometer. A value between 0 and 1023 is returned. If the potentiometer is turned all the way to the left, it produces a 0 value. If it is turned all the way tot the right, it produces a 1023 value. In the middle it produces a value around 512.PotentiometerPin the Potentiometer is connected to.0 1023
52Introduction of New ModulesA Motor is a electrical machine which converts electrical energy to mechanical energy. It is capable of rotating clockwise and counter clockwise. It is controlled by a Motor Con-troller. A Motor Controller can control up to 2 Motors. A Wheel can be attached to the Motor.MotorMotor Controller WheelMotor - Set Speed blockThis block sets the speed of the motor. Positive values turns the Motor in one direc-tion. While negative values turns the Motor in the opposite direction. A value of 0 stops the Motor. Values between -255 and 255 are accepted. 255 is maximum clock-wise speed. -255 is maximum counter-clockwise speed.Motor - Brake blockThis block sets the speed to 0 to stop the Motor.Motor to congure.Motor to congure.Speed to set.
53Review of BlocksAddition BlockThis block returns the sum of the left input and right input.Division BlockThis block returns the value of dividing the left input by the right input.Multiplication BlockThis block returns the product of the left input and right input.Subtraction BlockThis block returns the value of subtracting the left input by the right input.Less Than BlockThis block returns TRUE if the left input is less than the right input.Equal BlockThis block returns TRUE if the left input is equal to the right input.Greater Than BlockThis block returns TRUE if the left input is greater than the right input.
54Review of ConceptsCreating a Variable in ScratchClick on the “Variable” category.Then click on the “Create variable...” button.Name your variable.
55Review of ConceptsCreating a Variable in Scratch (continued)Several new blocks will appear which allows access and modication of the new variable.Variable Value blockVariable Set blockVariable Change blockThis block returns the current value of the variable.This block sets the value of the variable. It will overwrite the current value.This block changes the variable value by adding the input value (negative values or blocks are accepted).input value
56The ProblemHow can we create a motor controller with a revolutions indicator?
57Project WorksheetComplete the worksheet below to your best abilities.1. A solution.2. List all the parts needed for the solution. What is the purpose of each part?3. What is a simple explanation of the logic for the solution?4. Create a ow chart of the solution.5. How do you assemble and connect the modules for the solution?6. Congure blocks to relate to the ow chart.Use a Potentiometer to control the speed of the Motor. Use a Color LED to indicate the revolutions per minute.
58Project Worksheet - Answers2. List all the parts needed for the solution. What is the purpose of each part?1x mCenter+ - control the project, connect sensors and trinkets to project, and supply power.2x Hub Connector Cable - connect sensors and trinkets to the mCenter+.1x USB Cable - connect mCenter+ to a computer for charging and programming the project.1x Motor - motor to control the speed of.1x Potentiometer - used as an input to control the speed of the motor.1x Motor Controller - controls and drives the attached motors.1x Color LED - indicate the revolutions per minute of the motor.
59Project Worksheet - Answers3. What is a simple explanation of the logic for the solution?Use a Potentiometer as an input to adjust the speed of the Motor.Use a Color LED to indicate the current revolutions per minute.Read in the value of the Potentiometer (between 0 and 1023).Map the Motor’s speed based on the Potentiometer value (accepts values between 0 and 255).Map the Color LED’s brightness level based on the Potentiometer value (accepts values between 0 and 255).
60Project Worksheet - Answers4. Create a ow chart of the solution.StartRead and store the Potentiometer valueScale the Color LED brightness based on the Potentiometer valueScale the Motor speed based on the Potentiometer valueShort delayLoopforever.
61Project Worksheet - Answers5. How do you assemble and connect the modules for the solution?1.  Stack the Motor Controller onto the mCenter+.2.  Connect a Motor to connector “1A1B” on the Motor Controller.3.  Connect a Color LED (IN port) to pin 4/5.4.  Connect a Potentiometer to pin A0/A1.5.  Insert one end of the USB cable into mCenter+ and connect the other to a computer.D2/D3D8/D9I2C A2/A3I2CD4/D5A6/A7A0/A1I2CD6/D7
62Project Worksheet - Answers6. Congure blocks to relate to the ow chart.StartRead and store the Potentiometer valueScale the Color LED brightness based on the Potentiometer valueScale the Motor speed based on the Potentiometer valueShort delayLoopforever.
63The ScriptClick Green Flag to activate script. (Create “input” variable rst in the variable tab.)Read and store the valueof the Potentiometer (pin A0).Indicated the RPM withthe Color LED (pin 4).Set Motor (1) speed based on Potentiometer value.Short delay before looping.Loop.ControlEventsmCookieDataOperatorsArduinoBlock Locator
64Click the green ag to activate the script.1. Rotate the Potentiometer to adjust the speed of the Motor.The Motor and Color LED will react to the position of the Potentiometer.Testing the ProgramImportant: •  Ensure that mCenter+ is on. Flip the switch on mCenter+ to turn it on. An LED on mCenter+ will light up to indicate power is being supplied.•  Ensure you have selected the Serial Port and ashed the special rmware (mCookie) rst before testing (this only needs to be done once unless the rmware is overwritten).•  Ensure you have selected the Serial Port and connected before testing.Flash rmwareSelect Serial PortTesting:
65Create a StructureCreate a structure for the project using building blocks, paper, or other crafting materials.
66Project ChallengeScale the Potentiometer input so that the values between 0 and 511 causes the Motor to rotate backwards (-255~0).Scale the Potentiometer input so that the values between 512 and 1023 causes the Motor to rotate forwards (0~255).When the Motor is rotating backwards, make the Color LED red.When the Motor is rotating forwards, make the Color LED green.
67ReviewMotor Controller - controls and drives attached motors. Can control up to 2 motors.Motor - converts electrical energy into mechanical energy in the form of torque.Motor - Set Speed block - set the speed of a motor.Potentiometer - input module with an adjustable knob.Analog Read block - reads the value from the potentiometer. Returns a value between 0 and 1023.Color LED - congurable to display a wide range of colors.Color LED - Color Select block - congures what color a particular Color LED displays.
68Expanding the ProjectResearchWrite down a way of expanding this project. Create it on your own.Research more about revolutions per minute (RPM). List 5 contexts where this term is commonly used.______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
69Motion Sensor MotorMIX 4 - Project 2(Old Cards: MIX4A-02)
70About Roll, Pitch and YawAn aircraft in ight is free to rotate in three dimensions: pitch, nose up or down about an axis running from wing to wing; yaw, nose left or right about an axis running up and down; and roll, rotation about an axis running from nose to tail. The axes are alternatively designated as lateral, vertical, and longitudinal. These axes move with the vehicle and rotate relative to the Earth along with the craft. These denitions were analogously applied to spacecraft when the rst manned space-craft were designed in the late 1950s.These rotations are produced by torques (or moments) about the principal axes. On an aircraft, these are intentionally produced by means of moving control surfaces, which vary the distribution of the net aerodynamic force about the vehicle’s center of mass. Elevators (moving aps on the horizontal tail) produce pitch, a rudder on the vertical tail produces yaw, and ailerons (aps on the wings that move in opposing directions) produce roll. On a spacecraft, the moments are usually produced by a reaction control system consisting of small rocket thrusters used to apply asymmetrical thrust on the vehicle.Source: https://en.wikipedia.org/wiki/Aircraft_principal_axesYaw AxisRoll AxisPitch Axis
71Review of ModulesA Motor is a electrical machine which converts electrical energy to mechanical energy. It is capable of rotating clockwise and counter clockwise. It is controlled by a Motor Con-troller. A Motor Controller can control up to 2 Motors. A Wheel can be attached to the Motor.MotorMotor Controller WheelMotor - Set Speed blockThis block sets the speed of the motor. Positive values turns the Motor in one direc-tion. While negative values turns the Motor in the opposite direction. A value of 0 stops the Motor. Values between -255 and 255 are accepted. 255 is maximum clock-wise speed. -255 is maximum counter-clockwise speed.Motor - Brake blockThis block sets the speed to 0 to stop the Motor.Motor to congure.Motor to congure.Speed to set.
72Introduction of New ModulesThe Motion module is a triple axis accelerometer and gyroscope.It is capable of measuring on the X, Y & Z axis the:•  Angle•  Acceleration•  Angular velocityIt uses the “I2C” communication protocol and must be connected to and “I2C” port on mCenter+.MotionMotion - Read blockThis block reads data from the Motion module. It is capable of retrieving the angle, acceleration and angular velocity on the X, Y or Z axis.Angle, acceleration, or angular velocity to read.On the X, Y or Z axis.
73Review of BlocksAddition BlockThis block returns the sum of the left input and right input.Division BlockThis block returns the value of dividing the left input by the right input.Multiplication BlockThis block returns the product of the left input and right input.Subtraction BlockThis block returns the value of subtracting the left input by the right input.Less Than BlockThis block returns TRUE if the left input is less than the right input.Equal BlockThis block returns TRUE if the left input is equal to the right input.Greater Than BlockThis block returns TRUE if the left input is greater than the right input.
74Review of ConceptsCreating a Variable in ScratchClick on the “Variable” category.Then click on the “Create variable...” button.Name your variable.
75Review of ConceptsCreating a Variable in Scratch (continued)Several new blocks will appear which allows access and modication of the new variable.Variable Value blockVariable Set blockVariable Change blockThis block returns the current value of the variable.This block sets the value of the variable. It will overwrite the current value.This block changes the variable value by adding the input value (negative values or blocks are accepted).input value
76The ProblemHow can we control a motor using a motion module?
77Project WorksheetComplete the worksheet below to your best abilities.1. A solution.2. List all the parts needed for the solution. What is the purpose of each part?3. What is a simple explanation of the logic for the solution?4. Create a ow chart of the solution.5. How do you assemble and connect the modules for the solution?6. Congure blocks to relate to the ow chart.Use a Motion module to detect the pitch angle. Change the speed and direction of the Motor based on the pitch angle.
78Project Worksheet - Answers2. List all the parts needed for the solution. What is the purpose of each part?1x mCenter+ - control the project, connect sensors and trinkets to project, and supply power.1x Hub Connector Cable - connect sensors and trinkets to the mCenter+.1x USB Cable - connect mCenter+ to a computer for charging and programming the project.1x Motor - motor to control the speed of.1x Motion - detect motion.1x Motor Controller - controls and drives the attached motors.
79Project Worksheet - Answers3. What is a simple explanation of the logic for the solution?Use a Motion module to detect the pitch.Read and store the “X” angle (pitch).Constrain the value between -90 and 90.Multiple the value by 2.8 and use that to set the speed of the motor:•  -90 * 2.8 = -252•  90 * 2.8 = 252Produces a value between -252 and 252 for speed of the motor.
80Project Worksheet - Answers4. Create a ow chart of the solution.StartRead and store the raw pitch value from the Motion moduleIs the raw pitchvalue < -90?Is the raw pitchvalue > 90?Constrain the value to -90 and store itConstrain the value to 90 and store itStore the raw valueSet Motor speed based on constrained valueShort delayLoopforever.TrueTrueFalseFalse
81Project Worksheet - Answers5. How do you assemble and connect the modules for the solution?1.  Stack the Motor Controller onto the mCenter+.2.  Connect a Motor to connector “1A1B” on the Motor Controller.3.  Connect the Motion module to a “I2C” pin.4.  Insert one end of the USB cable into mCenter+ and connect the other to a computer.D2/D3D8/D9I2C A2/A3I2CD4/D5A6/A7A0/A1I2CD6/D7
82Project Worksheet - Answers6. Congure blocks to relate to the ow chart.StartRead and store the raw pitch value from the Motion moduleIs the raw pitchvalue < -90?Is the raw pitchvalue > 90?Constrain the value to -90 and store itConstrain the value to 90 and store itStore the raw valueSet Motor speed based on constrained valueShort delayLoopforever.TrueTrueFalseFalse
83The Script Block LocatorControlEventsmCookieDataOperatorsClick Green Flag to activate script.(Create “pitch_raw” and “pitch_constrained” variables rst in the variable tab.)Read and store the “X” angle from the Motion module.Check if the pitch (raw) value is < -90.Constrain it to -90. Check if the pitch (raw) value is > 90.Constrain it to 90. If between -90 and 90. Then accept the raw value.Set the Motor (1) speed based on the constrained “X” angle value.Short delay before looping.Loop.
84Click the green ag to activate the script.1. Rotate the Motion module along the “X” axis (pitch).2. The Motor will turn accordingly.Testing the ProgramImportant: •  Ensure that mCenter+ is on. Flip the switch on mCenter+ to turn it on. An LED on mCenter+ will light up to indicate power is being supplied.•  Ensure you have selected the Serial Port and ashed the special rmware (mCookie) rst before testing (this only needs to be done once unless the rmware is overwritten).•  Ensure you have selected the Serial Port and connected before testing.Flash rmwareSelect Serial PortTesting:
85Create a StructureCreate a structure for the project using building blocks, paper, or other crafting materials.
86Project ChallengeConstrain the “X” angle to -20 and 20.How does the motor react to this new constrained angle?
87ReviewMotor Controller - controls and drives attached motors. Can control up to 2 motors.Motor - converts electrical energy into mechanical energy in the form of torque.Motor - Set Speed block - set the speed of a motor.Motion - module which detects motion such as roll, paw and yaw.Motion - Read block - returns various motion readings from the Motion module.
88Expanding the ProjectResearchWrite down a way of expanding this project. Create it on your own.Research more about roll, pitch and yaw. Why is this information important to aircrafts?______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
89Motion Sensitive EmoticonMIX 4 - Project 3(Old Cards: MIX4A-03)
90About Vision StabilizationThe vestibulo-ocular reex (VOR) is a reex, where activation of the vestibular system causes eye movement. This reex functions to stabilize images on the retinas during head movement by producing eye movements in the direction opposite to head movement, thus preserving the image on the center of the visual eld(s).For example, when the head moves to the right, the eyes move to the left, and vice versa. Since slight head movement is present all the time, the VOR is very important for stabilizing vision: patients whose VOR is impaired nd it dicult to read using print, because they cannot stabilize the eyes during small head tremors, and also because damage to the VOR can cause vestibular nystagmus.Source: https://en.wikipedia.org/wiki/Vestibulo%E2%80%93ocular_reex
91Review of ModulesA Motor is a electrical machine which converts electrical energy to mechanical energy. It is capable of rotating clockwise and counter clockwise. It is controlled by a Motor Con-troller. A Motor Controller can control up to 2 Motors. A Wheel can be attached to the Motor.MotorMotor Controller WheelMotor - Set Speed blockThis block sets the speed of the motor. Positive values turns the Motor in one direc-tion. While negative values turns the Motor in the opposite direction. A value of 0 stops the Motor. Values between -255 and 255 are accepted. 255 is maximum clock-wise speed. -255 is maximum counter-clockwise speed.Motor - Brake blockThis block sets the speed to 0 to stop the Motor.Motor to congure.Motor to congure.Speed to set.
92Review of ModulesThe Motion sensor is a triple axis accelerometer and gyroscope.It is capable of measuring on the X, Y & Z axis the:•  Angle•  Acceleration•  Angular velocityIt uses the “I2C” communication protocol and must be connected to and “I2C” port on mCenter+.MotionMotion - Read blockThis block reads data from the Motion module. It is capable of retrieving the angle, acceleration and angular velocity on the X, Y or Z axis.Angle, acceleration, or angular velocity to read.On the X, Y or Z axis.
93Review of BlocksAddition BlockThis block returns the sum of the left input and right input.Division BlockThis block returns the value of dividing the left input by the right input.Multiplication BlockThis block returns the product of the left input and right input.Subtraction BlockThis block returns the value of subtracting the left input by the right input.Less Than BlockThis block returns TRUE if the left input is less than the right input.Equal BlockThis block returns TRUE if the left input is equal to the right input.Greater Than BlockThis block returns TRUE if the left input is greater than the right input.
94Review of ConceptsCreating a Variable in ScratchClick on the “Variable” category.Then click on the “Create variable...” button.Name your variable.
95Review of ConceptsCreating a Variable in Scratch (continued)Several new blocks will appear which allows access and modication of the new variable.Variable Value blockVariable Set blockVariable Change blockThis block returns the current value of the variable.This block sets the value of the variable. It will overwrite the current value.This block changes the variable value by adding the input value (negative values or blocks are accepted).input value
96The ProblemHow can we create a motion sensitive Emoticon robot?
97Project WorksheetComplete the worksheet below to your best abilities.1. A solution.2. List all the parts needed for the solution. What is the purpose of each part?3. What is a simple explanation of the logic for the solution?4. Create a ow chart of the solution.5. How do you assemble and connect the modules for the solution?6. Congure blocks to relate to the ow chart.Use the Motion module to detect the “X” angle (pitch). Set the eyes (2 Motors) spin speed based on the pitch value.
98Project Worksheet - Answers2. List all the parts needed for the solution. What is the purpose of each part?1x mCenter+ - control the project, connect sensors and trinkets to project, and supply power.1x Hub Connector Cable - connect sensors and trinkets to the mCenter+.1x USB Cable - connect mCenter+ to a computer for charging and programming the project.2x Motor - motor to simulate the robot’s eyes.1x Motion - detect motion.1x Motor Controller - controls and drives the attached motors.2x Wheel - attach to motor.
99Project Worksheet - Answers3. What is a simple explanation of the logic for the solution?Use a Motion module to detect the pitch.Use 2 Motors (with Wheels) to simulate the robot’s eyes.Read and store the “X” angle (pitch).Constrain the value between -20 and 20.Multiple the value by 5 and use that to set the speed of the motors:•  -20 * 5 = -100•  20 * 5 = 100Produces a value between -100 and 100 for speed of the motors.
100Project Worksheet - Answers4. Create a ow chart of the solution.StartRead and store the raw pitch value from the Motion moduleIs the raw pitchvalue < -20?Is the raw pitchvalue > 20?Constrain the value to -20 and store itConstrain the value to 20 and store itStore the raw valueSet Motors speed based on constrained valueShort delayLoopforever.TrueTrueFalseFalse
101Project Worksheet - Answers5. How do you assemble and connect the modules for the solution?1.  Stack the Motor Controller onto mCenter+.2.  Connect a Motor to connector “1A1B” on the Motor Controller.3.  Connect a Motor to connector “2A2B” on the Motor Controller.4.  Connect the Motion module to a “I2C” pin.5.  Insert one end of the USB cable into mCenter+ and connect the other to a computer.D2/D3D8/D9I2C A2/A3I2CD4/D5A6/A7A0/A1I2CD6/D7
102Project Worksheet - Answers6. Congure blocks to relate to the ow chart.StartRead and store the raw pitch value from the Motion moduleIs the raw pitchvalue < -20?Is the raw pitchvalue > 20?Constrain the value to -20 and store itConstrain the value to 20 and store itStore the raw valueSet Motors speed based on constrained valueShort delayLoopforever.TrueTrueFalseFalse
103The Script Block LocatorControlEventsmCookieDataOperatorsClick Green Flag to activate script.Read and store the “X” angle from the Motion module.Check if the pitch (raw) value is < -20.Constrain it to -20. Check if the pitch (raw) value is > 20.Constrain it to 20. If between -20 and 20. Then accept the raw value.Set the Motor (1) speed based on the constrained “X” angle value.Short delay before looping.Loop.Set the Motor (2) speed based on the constrained “X” angle value.
104Click the green ag to activate the script.1. Rotate the Motion module along the “X” axis (pitch).2. The Motors will turn accordingly.Testing the ProgramImportant: •  Ensure that mCenter+ is on. Flip the switch on mCenter+ to turn it on. An LED on mCenter+ will light up to indicate power is being supplied.•  Ensure you have selected the Serial Port and ashed the special rmware (mCookie) rst before testing (this only needs to be done once unless the rmware is overwritten).•  Ensure you have selected the Serial Port and connected before testing.Flash rmwareSelect Serial PortTesting:
105Create a StructureCreate a structure for the project using building blocks, paper, or other crafting materials.
106Project ChallengeIncrease the maximum speed in which the Motors can spin.Hint: Change the multiplication factor when setting the Motor speeds.Change the way the motors react to the pitch value to your liking.(Example, eyes rotating in opposing directions.)
107ReviewMotor Controller - controls and drives attached motors. Can control up to 2 motors.Motor - converts electrical energy into mechanical energy in the form of torque.Motor - Set Speed block - set the speed of a motor.Motion - module which detects motion such as roll, paw and yaw.Motion - Read block - returns various motion readings from the Motion module.Wheel - attaches to the Motor.
108Expanding the ProjectResearchWrite down a way of expanding this project. Create it on your own.Research other eye reexes such as the “Optokinetic response”. Why are these reexes important and why do they happen without your direct control?______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
109Single-axis Camera StabilizerMIX 4 - Project 4(Old Cards: MIX4A-04)
110A camera stabilizer, or camera–stabilizing mount, is a device designed to hold a camera in a manner that prevents or com-pensates for unwanted camera movement, such as “camera shake”.For small hand-held cameras, a harness or contoured frame steadies the camera against the photographer’s body. In some models, the camera mount is on an arm that protrudes in front of the photographer; beneath the camera is a handle grip. Another variation positions the camera atop a fulcrum braced against the photographer’s chest or abdomen.Source: https://en.wikipedia.org/wiki/Camera_stabilizerAbout Camera Stabilizers
111Review of ModulesA Servo is an actuator which consist of a motor and other electronic components which allows for precise angle adjustments of the attached horn. The servo included in the kit has an adjustable angle range between 0 and 180 degrees.AssemblyInstall the Servo into the Servo Block Connector and fasten with the included screws.Servo+ =ConnectivityA Servo Connector is required in order to connect the Servo to the Hub. The Servo Connector can support up 2 Servos at a time.First ServoSecond Servo+=Servo Servo Connector31 264 5123The top pins correspond to the odd pin on the Connector.The bottom pins correspond to the even pin on the Connector.For example, if the Servo Connector is connected to pin 6/7 on the Hub. The Servo connected to the top pins would be referenced as pin 7. The Servo con-nected to the bottom pins would be referenced as pin 6.Hub Connector Cable(to Hub)GND  1/2 VCC IMPORTANT: Ensure the Servo’s connector is in the correct orien-tation. As having the connector ipped can damage the servo or other components.31 264 5First ServoSecond ServoGND(Brown)VCC(Red)Signal Pin(Orange)456
112Review of ModulesServo (continued)UsageServo - Set Angle blockThe angle, between 0 and 180 degrees, is adjustable using blocks in Scratch. Calibrating your attachment (the horn) to your desired 0 angle can be done by rst set-ting the servo to 0 degrees, then attaching the horn as desired.Servo - Move From-To Angle blockSets the horn angle of the Servo. Quickly moves (as fast as possible) to the desired angle.Sets the horn angle from the starting angle to the target angle. This movement is performed in the specied duration time.Pin the Servo is connected to.Angle to set Servo to.Pin the Servo is connected to. Starting angle of Servo.Target angle for Servo.Time in millisecond to move from starting angle to target angle.
113Review of ModulesThe Motion sensor is a triple axis accelerometer and gyroscope.It is capable of measuring on the X, Y & Z axis the:•  Angle•  Acceleration•  Angular velocityIt uses the “I2C” communication protocol and must be connected to and “I2C” port on mCenter+.MotionMotion - Read blockThis block reads data from the Motion module. It is capable of retrieving the angle, acceleration and angular velocity on the X, Y or Z axis.Angle, acceleration, or angular velocity to read.On the X, Y or Z axis.
114Review of BlocksAddition BlockThis block returns the sum of the left input and right input.Division BlockThis block returns the value of dividing the left input by the right input.Multiplication BlockThis block returns the product of the left input and right input.Subtraction BlockThis block returns the value of subtracting the left input by the right input.Less Than BlockThis block returns TRUE if the left input is less than the right input.Equal BlockThis block returns TRUE if the left input is equal to the right input.Greater Than BlockThis block returns TRUE if the left input is greater than the right input.
115The ProblemHow can we create a one-axis camera stabilizer?
116Project WorksheetComplete the worksheet below to your best abilities.1. A solution.2. List all the parts needed for the solution. What is the purpose of each part?3. What is a simple explanation of the logic for the solution?4. Create a ow chart of the solution.5. How do you assemble and connect the modules for the solution?6. Congure blocks to relate to the ow chart.Use the Motion module to detect the current “Y” angle. Stabilize the project using a Servo compensating for the  “Y” angle value.
117Project Worksheet - Answers2. List all the parts needed for the solution. What is the purpose of each part?1x mCenter+ - control the project, connect sensors and trinkets to project, and supply power.2x Hub Connector Cable - connect sensors and trinkets to the mCenter+.1x USB Cable - connect mCenter+ to a computer for charging and programming the project.1x Servo - to steady the camera.1x Servo Connector - connect a Servo to mCenter+.1x Motion - detect the un-stabilized angle.
118Project Worksheet - Answers3. What is a simple explanation of the logic for the solution?Use a Motion module to detect the “Y” angle. The Motion module must lay horizontal.Use a Servo to compensate for the “Y” angle for stabilization.Read “Y” angle.Set the Servo to compensate for the “Y” angle by adding 90.Display the angle the Servo is set to.
119Project Worksheet - Answers4. Create a ow chart of the solution.StartRead the "Y" anglefrom the Motion moduleSet the Servo angle to compensate for the "Y" angle.Display the anglethe Servo was set toShort delayLoopforever.
120Project Worksheet - Answers5. How do you assemble and connect the modules for the solution?1.  Connect a Servo Connector to pin 6/7 using a Hub Connector Cable. 2.  Connect two Servos to the Servo Connector. Ensure the connector is in the correct orientation.3.  Connect the Motion module to a “I2C” pin.4.  Insert one end of the USB cable into mCenter+ and connect the other to a computer.GND  1/2 VCC IMPORTANT: Ensure the Servo’s connector is in the correct orien-tation. As having the connector ipped can damage the servo or other components.31 264 5First ServoSecond ServoGND(Brown)VCC(Red)Signal Pin(Orange)D2/D3D8/D9I2C A2/A3I2CD4/D5A6/A7A0/A1I2CD6/D7
121Project Worksheet - Answers6. Congure blocks to relate to the ow chart.StartRead the "Y" anglefrom the Motion moduleSet the Servo angle to compensate for the "Y" angle.Display the anglethe Servo was set toShort delayLoopforever.
122The Script Block LocatorClick Green Flag to activate script.Short delay before looping.Loop.Read “Y” angle and compensate with Servo (pin 6).Display the Servo angle on the stage.ControlEventsmCookieOperatorsArduinoLooks*** Enable this block under settings (gear icon on top right). Then select Kit > mCookie Extension.  ***
123Click the green ag to activate the script. 1. Rotate the Motion module. 2. The Servo will rotate to compensate.Testing the ProgramImportant: •  Ensure that mCenter+ is on. Flip the switch on mCenter+ to turn it on. An LED on mCenter+ will light up to indicate power is being supplied.•  Ensure you have selected the Serial Port and ashed the special rmware (mCookie) rst before testing (this only needs to be done once unless the rmware is overwritten).•  Ensure you have selected the Serial Port and connected before testing.Flash rmwareSelect Serial PortTesting:Note: If the program is working correctly and you wish to use the program without being connected to your computer. Switch to Arduino mode (top right), then “Flash Program” (this overrides the special rmware, you will need to reash to use Live mode).
124Create a StructureCreate a structure for the project using building blocks, paper, or other crafting materials.
125Project ChallengeAdd a Color LED to the project. Use it to indicate when the camera stabilizer is at an extreme angle.
126ReviewServo - an actuator with precise angle control.Servo Connector - an adapter to connect a Servo to the Hub on mCenter+.Servo - Set Angle block - Sets the angle of the Servo. Quickly moves (as fast as possible) to the desired angle.Motion - module which detects motion such as roll, paw and yaw.Motion - Read block - returns various motion readings from the Motion module.
127Expanding the ProjectResearchWrite down a way of expanding this project. Create it on your own.Research other things self-stabilize. What are some very important life saving applications of this principle?______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
128Air BagMIX 4 - Project 5(Old Cards: MIX4A-06)
129An airbag is a type of vehicle safety device and is an occupant restraint system. The airbag module is designed to inate extremely rapidly, then quickly deate during a collision or impact with a surface or a rapid sudden deceleration. It consists of the airbag cushion, a exible fabric bag, ination module and im-pact sensor. The purpose of the airbag is to provide the occupants a soft cushioning and restraint during a crash event to prevent or reduce any impact or impact-caused injuries between the ailing occupant and the interior of the vehicle. The airbag also provides an energy absorbing surface between the vehi-cle’s occupant and a steering wheel, instrumental panel, A-B-C- structural body frame pillars, headliner and windshield/windscreen.Source: https://en.wikipedia.org/wiki/AirbagAbout Airbags
130Review of ModulesThe Color LED is a LED composed of 3 smaller LEDs which emit red, green, and blue. Each color’s brightness value can be congured individually. This can produce a wide variety of colors. It is controlled over a special communication protocol which is dier-ent from the basic “Digital Output” (used by Single-Color LED).UsageColor LEDThis block congures what color a particular Color LED displays.Hub pin the 1st Color LED is connected.Transition fromthis color.Transition tothis color.Color LED - Color Select blockColor LED - Color Transition blockThis block causes a particular Color LED to transition from one color to another color under a time span. (Note: This block must complete its transition before proceeding to the next block in the script.)Index of the Color LED to congure.Color to changethe Color LED to.Hub pin the 1st Color LED is connected.Set duration (in milliseconds)for the transition.•  The Color LED connected directly to the Hub is index 0.•  The Color LED connected next in the chain is index 1.•  And so on.Indexing2/38/9I2C A2/A3I2CI2C4/5A6/A7A0/A16/7IN INOUT OUTIndex of the Color LED to congure.ColorLEDIndex: 0ColorLEDIndex: 1
131Review of ModulesThe Motion sensor is a triple axis accelerometer and gyroscope.It is capable of measuring on the X, Y & Z axis the:•  Angle•  Acceleration•  Angular velocityIt uses the “I2C” communication protocol and must be connected to and “I2C” port on mCenter+.MotionMotion - Read blockThis block reads data from the Motion module. It is capable of retrieving the angle, acceleration and angular velocity on the X, Y or Z axis.Angle, acceleration, or angular velocity to read.On the X, Y or Z axis.
132Review of BlocksAddition BlockThis block returns the sum of the left input and right input.Division BlockThis block returns the value of dividing the left input by the right input.Multiplication BlockThis block returns the product of the left input and right input.Subtraction BlockThis block returns the value of subtracting the left input by the right input.Less Than BlockThis block returns TRUE if the left input is less than the right input.Equal BlockThis block returns TRUE if the left input is equal to the right input.Greater Than BlockThis block returns TRUE if the left input is greater than the right input.
133Review of ConceptsCreating a Variable in ScratchClick on the “Variable” category.Then click on the “Create variable...” button.Name your variable.
134Review of ConceptsCreating a Variable in Scratch (continued)Several new blocks will appear which allows access and modication of the new variable.Variable Value blockVariable Set blockVariable Change blockThis block returns the current value of the variable.This block sets the value of the variable. It will overwrite the current value.This block changes the variable value by adding the input value (negative values or blocks are accepted).input value
135The ProblemHow can we detect large deceleration forces and indicated when detected?
136Project WorksheetComplete the worksheet below to your best abilities.1. A solution.2. List all the parts needed for the solution. What is the purpose of each part?3. What is a simple explanation of the logic for the solution?4. Create a ow chart of the solution.5. How do you assemble and connect the modules for the solution?6. Congure blocks to relate to the ow chart.Use the Motion module to detect a large deceleration. Use a Color LED to indicate a large deceleration has occured.
137Project Worksheet - Answers2. List all the parts needed for the solution. What is the purpose of each part?1x mCenter+ - control the project, connect sensors and trinkets to project, and supply power.2x Hub Connector Cable - connect sensors and trinkets to the mCenter+.1x USB Cable - connect mCenter+ to a computer for charging and programming the project.1x Motion - to detect large acceleration forces.1x Color LED - indicate when a large acceleration is detected.
138Project Worksheet - Answers3. What is a simple explanation of the logic for the solution?Large deceleration occurs when a sudden stop happens, such as when avoiding a car accident.Use the Motion module to detect a large negative deceleration (sudden stop).Use the Color LED to indicate when such force has been detected.Read the “Y” acceleration. Check if it is a large negative value, which occurs during a sudden stop.If there is a large value, then ash the Color LED to indicate it has occurred.
139Project Worksheet - Answers4. Create a ow chart of the solution.StartRead and store the "Y" acceleration valuefrom the Motion moduleDoes the "Y" acceleration indicate a sudden stop?(value < -5000)Flash the Color LEDto indicate a sudden stopShort delayLoopforever.TrueFalse
140Project Worksheet - Answers5. How do you assemble and connect the modules for the solution?1.  Connect the Motion module to a “I2C” pin.2.  Connect a Color LED (IN port) to pin 6/7.3.  Insert one end of the USB cable into mCenter+ and connect the other to a computer.D2/D3D8/D9I2C A2/A3I2CD4/D5A6/A7A0/A1I2CD6/D7
141Project Worksheet - Answers6. Congure blocks to relate to the ow chart.StartRead and store the "Y" acceleration valuefrom the Motion moduleDoes the "Y" acceleration indicate a sudden stop?(value < -5000)Flash the Color LEDto indicate a sudden stopShort delayLoopforever.TrueFalse
142The Script Block Locator(Create “accel” variable rst in the variable tab.)Click Green Flag to activate script.Read and store the “Y” acceleration from the Motion module.Check if there is a large negative acceleration (sudden stop).If there is, ash Color LED (pin 6).Short delay before looping.Loop.ControlEventsmCookieDataOperators
143Click the green ag to activate the script.1. Create a large negative acceleration force (sudden stop).2. When a large negative acceleration occurs, the Color LED will ash.Testing the ProgramImportant: •  Ensure that mCenter+ is on. Flip the switch on mCenter+ to turn it on. An LED on mCenter+ will light up to indicate power is being supplied.•  Ensure you have selected the Serial Port and ashed the special rmware (mCookie) rst before testing (this only needs to be done once unless the rmware is overwritten).•  Ensure you have selected the Serial Port and connected before testing.Flash rmwareSelect Serial PortTesting:
144Create a StructureCreate a structure for the project using building blocks, paper, or other crafting materials.
145Project ChallengeCreate your own lighting eects when a sudden stop occurs.How would you detect a large forward acceleration?Modify the script to indicate when a large forward acceleration occurs.
146ReviewMotion - module which detects motion such as roll, paw and yaw.Motion - Read block - returns various motion readings from the Motion module.Color LED - congurable to display a wide range of colors.Color LED - Color Select block - congures what color a particular Color LED displays.
147Expanding the ProjectResearchWrite down a way of expanding this project. Create it on your own.Research more about the history of airbags. Besides being in cars, what other places are airbags used?______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
148Wired RC CardMIX 4 - Project 6(Old Cards: MIX4B-01)
149Radio controlled (or R/C) cars are battery/gas-powered model cars or trucks that can be controlled from a distance using a specialized transmitter or remote. The term “R/C” has been used to mean both “remote controlled” and “radio controlled”, where “remote controlled” includes vehicles that are connected to their controller by a wire, but common use of “R/C” today usually refers to vehicles controlled by a radio-fre-quency link. This section focuses on radio-controlled vehicles only.Source: https://en.wikipedia.org/wiki/Radio-controlled_carAbout RC Cars
150Review of ModulesA Joystick is an input module (sensor) which can sense if the stick is in the up, down, left or right positions.In addition, it can sense if it is being pressed (pressing directly on stick).JoystickUpLeft RightDownPressUsageThe Joystick must be connected to an “Analog Read” compatible pin. These are the pins prexed with an “A” (pins A0 to A7).Joystick State blockOn the dened Joystick pin, if the stick’s position (up, down, left, right or center (pressed)) matches the state (released, pressed or pressing), then this block returns TRUE. Otherwise, this block returns FALSE.Pin Joystick is connected to.Stick position to check.Stick position’s state to match.
151Review of ModulesA Motor is a electrical machine which converts electrical energy to mechanical energy. It is capable of rotating clockwise and counter clockwise. It is controlled by a Motor Con-troller. A Motor Controller can control up to 2 Motors. A Wheel can be attached to the Motor.MotorMotor Controller WheelMotor - Set Speed blockThis block sets the speed of the motor. Positive values turns the Motor in one direc-tion. While negative values turns the Motor in the opposite direction. A value of 0 stops the Motor. Values between -255 and 255 are accepted. 255 is maximum clock-wise speed. -255 is maximum counter-clockwise speed.Motor - Brake blockThis block sets the speed to 0 to stop the Motor.Motor to congure.Motor to congure.Speed to set.
152Review of BlocksAddition BlockThis block returns the sum of the left input and right input.Division BlockThis block returns the value of dividing the left input by the right input.Multiplication BlockThis block returns the product of the left input and right input.Subtraction BlockThis block returns the value of subtracting the left input by the right input.Less Than BlockThis block returns TRUE if the left input is less than the right input.Equal BlockThis block returns TRUE if the left input is equal to the right input.Greater Than BlockThis block returns TRUE if the left input is greater than the right input.
153Review of ConceptsCreating a Variable in ScratchClick on the “Variable” category.Then click on the “Create variable...” button.Name your variable.
154Review of ConceptsCreating a Variable in Scratch (continued)Several new blocks will appear which allows access and modication of the new variable.Variable Value blockVariable Set blockVariable Change blockThis block returns the current value of the variable.This block sets the value of the variable. It will overwrite the current value.This block changes the variable value by adding the input value (negative values or blocks are accepted).input value
155The ProblemHow can we create a RC car controllable with a joystick module?

Navigation menu