Microduino MIXC104E KIT-mCookie-Education User Manual MIX4 Book 02202018 SS indd

Microduino Inc. KIT-mCookie-Education MIX4 Book 02202018 SS indd

Contents

User manual Part 2

156Project 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 two Motors to move the car. Use the Joystick to receive input from the user to go straight, turn left or right. Adjust the speed of the Motors accordingly.
157Project 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 - to move the RC car.1x Motor Controller - controls and drives the attached motors.1x Joystick - to the direction of the RC car. 2x Wheel - attach to motor.
158Project Worksheet - Answers3. What is a simple explanation of the logic for the solution?Use two Motors to move the RC car.Use the Joystick to input the direction to move the car (left, right, up, down).Depending on the Joystick’s direction being held down:•  Up - move car forward (both motors rotating forward).•  Down - move car backward (both motors rotating backwards).•  Left - move car left (motor 1 rotating forward slowly, motor 2 rotating forward fast).•  Right - move car right (motor 1 rotating forward fast, motor 2 rotating forward slowly).•  None - stop car (both motors turned o).For Left and Right directions, the dierence in motor speeds causes the car to turn.Turning Left Turning RightForward
159Project Worksheet - Answers4. Create a ow chart of the solution.StartSet variable for motor speedIs Joystick "Up"being pressed?Is Joystick "Down"being pressed?Is Joystick "Left"being pressed?Is Joystick "Right"being pressed?Set motors to moveRC car forwardSet motors to moveRC car backwardSet motors to turnRC car leftSet motors to turnRC car rightSet motors to off(stop RC car)Short delayLoopforever.TrueTrueTrueTrueFalseFalseFalseFalse
160Project 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 Joystick 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
161Project Worksheet - Answers6. Congure blocks to relate to the ow chart.StartSet variable for motor speedIs Joystick "Up"being pressed?Is Joystick "Down"being pressed?Is Joystick "Left"being pressed?Is Joystick "Right"being pressed?Set motors to moveRC car forwardSet motors to moveRC car backwardSet motors to turnRC car leftSet motors to turnRC car rightSet motors to off(stop RC car)Short delayLoopforever.TrueTrueTrueTrueFalseFalseFalseFalse
162The Script Block LocatorLoop.Click Green Flag to activate script.Short delay before looping.Set the variable for the speed of the motors.Check if the Joystick (pin A0) “Up” key is being pressed.Check if the Joystick (pin A0) “Right” key is being pressed.Check if the Joystick (pin A0) “Left” key is being pressed.Check if the Joystick (pin A0) “Down” key is being pressed.Set motors to move car forward.Set motors to move car backward.Set motors to turn car left.Set motors to turn car right.Otherwise (no key being pressed), turn motors o.ControlEventsmCookieDataOperators(Create “motor_speed” variable rst in the variable tab.)
163Click the green ag to activate the script.1. Press and hold the Joystick in the Up, Down, Left or Right position.2. The Motors will turn accordingly to move the RC car.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).
164Create a StructureCreate a structure for the project using building blocks, paper, or other crafting materials.
165Project ChallengeHow can you modify the speed in which the car moves?Adjust the turning radius (quicker turning).Add another Joystick input (“Center” pressing).Make this input to cause the car to spin (motor 1 forward, motor 2 backward).
166ReviewMotor 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.Wheel - attaches to the Motor.Joystick - input module (sensor) which can detect the position of the stick (up, down, left, right, center (press)). Joystick State block - returns TRUE if the position of the stick state matches the checking state. Otherwise returns FALSE.
167Expanding the ProjectResearchWrite down a way of expanding this project. Create it on your own.Research more about the history of RC cars. Besides being controllable directly by a wired Joystick, what other methods are used to control RC cars?______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
168Safety CarMIX 4 - Project 7(Old Cards: MIX4B-02)
169A collision avoidance system is an automobile safety system designed to reduce the severity of a collision. It is also known as a precrash system, forward collision warning system, or collision mitigating system. It uses radar (all-weather) and sometimes laser (LIDAR) and camera (employing image recognition) to de-tect an imminent crash. GPS sensors can detect xed dangers such as approaching stop signs through a location database.Once the detection is done, these systems either provide a warning to the driver when there is an im-minent collision or take action autonomously without any driver input (by braking or steering or both). Collision avoidance by braking is appropriate at low vehicle speeds (e.g. below 50 km/h), while collision avoidance by steering is appropriate at higher vehicle speeds. Cars with collision avoidance may also be equipped with adaptive cruise control, and use the same forward-looking sensors.Source: https://en.wikipedia.org/wiki/Collision_avoidance_systemAbout Collision Avoidance
170Review of ModulesUsageThe 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).Line FinderAnalog 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 Returned
171Review 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 two 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.
172Review 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.
173Review of ConceptsCreating a Variable in ScratchClick on the “Variable” category.Then click on the “Create variable...” button.Name your variable.
174Review 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
175The ProblemHow can we create an autonomous car which moves forward until it reaches an object, then moves backwards until it reaches an object, then repeats?
176Project 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 two Line Finders to detect obstacles (objects) in the front and back of the car. Use two motors to move the car.
177Project 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.2x Motor - to move the RC car.1x Motor Controller - controls and drives the attached motors.2x Wheel - attach to motor.2x Line Finder - detect objects in the front and back of the car.
178Project Worksheet - Answers3. What is a simple explanation of the logic for the solution?Use two Motors to move the RC car.Use two Line Finders (one in front, one in back) to detect objects in the way.Move forward until an object is detected (Line Finder in front value < 700).Move backward until an object is detected (Line Finder in back value < 700).Repeat.
179Project Worksheet - Answers4. Create a ow chart of the solution.StartSet variable for motor speedShort delayLine Finder (front)doesn’t detect an objectLine Finder (back)doesn’t detect an objectSet motors to moveRC car forwardSet motors to moveRC car backwardShort delayShort delayTrueTrueFalseFalseLoopforever.
180Project 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 a Line Finder to pin A0/A1.5.  Connect a Line Finder to pin A2/A3.6.  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
181Project Worksheet - Answers6. Congure blocks to relate to the ow chart.StartSet variable for motor speedShort delayLine Finder (front)doesn’t detect an objectLine Finder (back)doesn’t detect an objectSet motors to moveRC car forwardSet motors to moveRC car backwardShort delayShort delayTrueTrueFalseFalseLoopforever.
182The Script Block LocatorLoop.Click Green Flag to activate script.Short delay before looping.(Create “motor_speed” variable rst in the variable tab.)Set the variable for the speed of the motors.Repeat until Line Finder (A0) in front detects an object.Repeat until Line Finder (A2) in back detects an object.Short delay before looping.Short delay before looping.Set motors to move car forward.Set motors to move car backward.ControlEventsmCookieDataOperatorsArduino
183Click the green ag to activate the script.1. The car will move forward until the Line Finder (front) detects an object.2. The car will then move backward until the Line Finder (back) detects an object.3. Repeat.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).
184Create a StructureCreate a structure for the project using building blocks, paper, or other crafting materials.
185Project ChallengeModify the script to use “If Else” blocks instead of “Repeat Until” blocks.Add a third condition check to stop the car if both Line Finders detect an object.
186ReviewMotor 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.Wheel - attaches to the Motor.Line Finder - detects the reective surface or distance of an object.Analog Read block - returns the value of the reective surface from the Line Finder sensor.
187Expanding the ProjectResearchWrite down a way of expanding this project. Create it on your own.Research more about obstacle avoidance systems in cars.What are some interesting techniques that are used in these systems?______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
188Delivery TruckMIX 4 - Project 8(Old Cards: MIX4B-03)
189Delivery is the process of transporting goods from a source location to a predened destination. There are dierent delivery types. Cargo (physical goods) are primarily delivered via roads and railroads on land, shipping lanes on the sea and airline networks in the air. Certain specialized goods may be delivered via other networks, such as pipelines for liquid goods, power grids for electrical power and computer net-works such as the Internet or broadcast networks for electronic information.The general process of delivering goods is known as distribution. The study of eective processes for delivery and disposition of goods and personnel is called logistics. Firms that specialize in delivering com-mercial goods from point of production or storage to point of sale are generally known as distributors, while those that specialize in the delivery of goods to the consumer are known as delivery services. Post-al, courier, and relocation services also deliver goods for commercial and private interests.Source: https://en.wikipedia.org/wiki/Delivery_(commerce)About Deliveries
190Review of ModulesUsageThe 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).Line FinderAnalog 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 Returned
191Review 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
192Review 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 two 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.
193Review 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.
194Review of ConceptsCreating a Variable in ScratchClick on the “Variable” category.Then click on the “Create variable...” button.Name your variable.
195Review 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
196The ProblemHow can we create a delivery truck with adjustable speeds? Which waits for something to be loaded, then drives it to the destination, waits for it to be unloaded, then drives back.
197Project 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 two motors to move the delivery truck. Use a Line Finder to detect if cargo is present or not. Use a Line Finder (front) to check if the destination is reached. Use a Line Finder (back) to check if returned back to base. Use a Potentiometer to adjust the speed of the truck.
198Project 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.5x 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 - to move the delivery truck.1x Motor Controller - controls and drives the attached motors.2x Wheel - attach to motor.3x Line Finder - detect objects in the front and back of the car and if cargo is present.1x Potentiometer - to adjust speed of the truck.1x IO Splitter - to connect two sensors/trinkets to a single connector.
199Project Worksheet - Answers3. What is a simple explanation of the logic for the solution?Use two Motors to move the delivery truck.Use a Line Finder in the cargo holding location to detect if cargo is loaded or unloaded.Use a Line Finder in the front to detect if the destination has been reached.Use a Line Finder in the back to detect if returned to base.Use a Potentiometer to adjust the speed of the delivery truck.Wait until cargo is loaded onto truck (Line Finder in cargo holding < 200).Wait 1 second before driving to destination.Move forward* until destination is reached (Line Finder in front < 700).Wait until cargo is unloaded from truck (Line Finder in cargo holding > 400).Wait 1 second before driving back to base.Move backward* until back to base (Line Finder in back < 700).*When setting the speed to move forward or backward, read the Potentiometer (value between 0 and 1023) rst, then scale (divide by 4, 1023/4 =~ 255) and use that as the speed.
200Project Worksheet - Answers4. Create a ow chart of the solution.StartSet variable for motor speedSet motors to off(stop the truck)Wait until cargo is loadedShort delay before driving to destinationRead and store Potentiometer and scale it for motor speedSet motors to movetruck forwardSet motors to movetruck backwardWait until truck has reach its destinationSet motors to off(stop the truck)Wait until cargo is unloadedShort delay before driving back to baseWait until truck has reach back to baseLoopforever.
201Project 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 a Line Finder to pin A2/A3.5.  Connect a Potentiometer to pin A6/A76.  Connect two Line Finders to an IO Splitter. Connect the IO Splitter to pin A0/A1.7.  Insert one end of the USB cable into mCenter+ and connect the other to a computer.D2/D3D8/D9I2C A2/A3I2CD4/D5A6/A7A0/A1I2CD6/D7IN B
202Project Worksheet - Answers6. Congure blocks to relate to the ow chart.StartSet variable for motor speedSet motors to off(stop the truck)Wait until cargo is loadedShort delay before driving to destinationRead and store Potentiometer and scale it for motor speedSet motors to movetruck forwardSet motors to movetruck backwardWait until truck has reach its destinationSet motors to off(stop the truck)Wait until cargo is unloadedShort delay before driving back to baseWait until truck has reach back to baseLoopforever.
203The Script Block LocatorLoop.Click Green Flag to activate script.Wait until Line Finder (A2) in back detects returning to base.(Create “motor_speed” variable rst in the variable tab.)ControlEventsmCookieDataOperatorsArduinoSet the variable for the speed of the motors.Turn motors o (stop the truck).Wait until Line Finder (A0) detects cargo (loaded).Wait 1 second before driving to destination.Wait 1 second before driving back to base.Scale and store Potentiometer (pin A6) value to motor speed.Scale and store Potentiometer (pin A6) value to motor speed.Set motors to move truck forward.Set motors to move truck backward.Wait until Line Finder (A1) in front detects reaching destination.Turn motors o (stop the truck).Wait until Line Finder (A0) detects no cargo (unloaded).
204Click the green ag to activate the script. 1. Load cargo into the truck.2. The truck will then move forward until it research its destination (object blocking its path in the front).3. Truck will stop and wait until cargo is unloaded.4. The truck will then move backward until it research its base (object blocking its path in the back).Line Finder (pin A0)Line Finder (pin A1)Line Finder (pin A2)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).
205Create a StructureCreate a structure for the project using building blocks, paper, or other crafting materials.
206Project ChallengeAdd a Color LED to your project.Turn set the Color LED’s based on the state the delivery truck.(Examples: loaded cargo, stopped, moving, unloaded cargo.)
207ReviewMotor 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.Wheel - attaches to the Motor.Line Finder - detects the reective surface or distance of an object.Analog Read block - returns the value of the reective surface from the Line Finder sensor.Potentiometer - input module with an adjustable knob.Analog Read block - reads the value from the potentiometer. Returns a value between 0 and 1023.
208Expanding the ProjectResearchWrite down a way of expanding this project. Create it on your own.Research more about delivery trucks. What are some important things delivery trucks must accomplish to be protable?______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
209Obstacle Avoidance CarMIX 4 - Project 9(Old Cards: MIX4B-04)
210In robotics, obstacle avoidance is the task of satisfying some control objective subject to non-intersection or non-collision position constraints.What is critical about obstacle avoidance concept in this area is the growing need of usage of unmanned aerial vehicles in urban areas for especially military applications where it can be very useful in city wars. Normally obstacle avoidance is considered to be distinct from path planning in that one is usually imple-mented as a reactive control law while the other involves the pre-computation of an obstacle-free path which a controller will then guide a robot along.Source: https://en.wikipedia.org/wiki/Obstacle_avoidanceAbout Obstacle Avoidance
211Review of ModulesUsageThe 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).Line FinderAnalog 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 Returned
212Review 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
213Review 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.
214Review 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.
215Review of ConceptsCreating a Variable in ScratchClick on the “Variable” category.Then click on the “Create variable...” button.Name your variable.
216Review 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
217The ProblemHow can we create a car which can detect and avoid objects in the way?
218Project 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 two motors to move the car. Use 4 Line Finder positioned in front of the car to detect oncoming objects. Use this information to steer the car away to avoid the object. Use a Potentiometer to set the motor speeds.
219Project 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.7x 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 - to move the car.1x Motor Controller - controls and drives the attached motors.2x Wheel - attach to motor.4x Line Finder - detect objects oncoming objects.1x Potentiometer - to adjust speed of the car.2x IO Splitter - to connect two sensors/trinkets to a single connector.
220Project Worksheet - Answers3. What is a simple explanation of the logic for the solution?Use two Motors to move the car.Use 4 Line Finders placed in front of the car to detect oncoming objects.Use a Potentiometer to set the speed of the car.S0, S1, S2, S3 are the 4 Line Finders placed in front of the car.If S0 detects an object, steer to the right.Else if S1 detects an object, steer to the right.Else if S2 detects an object, steer to the left.Else if S3 detects an object, steer to the left.Else no objects are detected, go forward.S0 S1 S2 S3S0 S1 S2 S3 S0 S1 S2 S3
221Project Worksheet - Answers4. Create a ow chart of the solution.StartRead and store Potentiometer and scale it for motor speedRead and store Line FindervaluesIs there an object detected on the left most side (S0)?Is there an object detected on the left middle side (S1)?Is there an object detected on the right most side (S3)?Is there an object detected on the right middle side (S2)?Set motors to turn car rightSet motors to turn car rightSet motors to turn car leftSet motors to turn car leftOtherwise there is no obstacle,set motors to go forwardShort delayLoopforever.TrueTrueTrueTrueFalseFalseFalseFalse
222Project 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 a Potentiometer to pin A6/A75.  Connect two Line Finders to an IO Splitter. Connect the IO Splitter to pin A0/A1.6.  Connect two Line Finders to an IO Splitter. Connect the IO Splitter to pin A2/A3.7.  Insert one end of the USB cable into mCenter+ and connect the other to a computer.D2/D3D8/D9I2C A2/A3I2CD4/D5A6/A7I2CD6/D7A0/A1IN BIN B
223Project Worksheet - Answers6. Congure blocks to relate to the ow chart.StartRead and store Potentiometer and scale it for motor speedRead and store Line FindervaluesIs there an object detected on the left most side (S0)?Is there an object detected on the left middle side (S1)?Is there an object detected on the right most side (S3)?Is there an object detected on the right middle side (S2)?Set motors to turn car rightSet motors to turn car rightSet motors to turn car leftSet motors to turn car leftOtherwise there is no obstacle,set motors to go forwardShort delayLoopforever.TrueTrueTrueTrueFalseFalseFalseFalse
224The Script Block LocatorLoop.Click Green Flag to activate script.Short delay before looping.(Create these variables rst in the variable tab.)ControlEventsmCookieDataOperatorsArduinoScale and store Potentiometer (pin A6) value to motor speed.Read and store Line Finder (pin A0) value.Read and store Line Finder (pin A1) value.Read and store Line Finder (pin A2) value.Read and store Line Finder (pin A3) value.Check if there is an oncoming object on the left most side.Check if there is an oncoming object on the left center side.Check if there is an oncoming object on the right center side.Check if there is an oncoming object on the right most side.Otherwise no coming objects. Set motors to move car forward.Set motors to turn car left.Set motors to turn car left.Set motors to turn car right.Set motors to turn car right.
225Click the green ag to activate the script.Ensure Line Finders are in the correct position.S0 S1 S2 S3Car will automatically avoid oncoming objects by steering left or right.Speed can be adjusted with 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: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).
226Create a StructureCreate a structure for the project using building blocks, paper, or other crafting materials.
227Project ChallengeAdjust the script so the car turns slightly right when it detects an object on the left most side (S0).Adjust the script so the car turns slightly left when it detects an object on the right most side (S3).
228ReviewMotor 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.Wheel - attaches to the Motor.Line Finder - detects the reective surface or distance of an object.Analog Read block - returns the value of the reective surface from the Line Finder sensor.Potentiometer - input module with an adjustable knob.Analog Read block - reads the value from the potentiometer. Returns a value between 0 and 1023.
229Expanding the ProjectResearchWrite down a way of expanding this project. Create it on your own.Research more about obstacle avoidance.Why is this an important feature in safe driving cars?______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
230Edge Avoidance CarMIX 4 - Project 10(Old Cards: MIX4B-06)
231If you put the a cleaning robot on a desk it won’t fall onto the ground, because there are sensors detecting distance from the ground at the bottom of it. Source: https://en.wikipedia.org/wiki/Obstacle_avoidanceAbout Edge Detection
232Review of ModulesUsageThe 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).Line FinderAnalog 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 Returned
233Review of ModulesReview 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.
234Review 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.
235Review of ConceptsBooleansBooleans are a type of data, which can only either be TRUE or FALSE. Booleans are used in the condition checks on blocks such as the “If”, “If Else”, “Wait Until” blocks.Boolean OperatorsBoolean Operators enables performing operations on boolean types. It is useful for testing multiple conditions.Left Input Right Input ResultTrue True TrueTrue False FalseFalse True FalseFalse False FalseLeft Input Right Input ResultTrue True TrueTrue False TrueFalse True TrueFalse False FalseInput ResultTrue FalseFalse TrueAnd blockOr blockNot blockThis block returns TRUE, when both the inputs are TRUE. Otherwise, it returns FALSE.This block returns TRUE, when one of the input isTRUE. Otherwise, it returns FALSE.This block returns the opposite of the input. If in-put is TRUE, this returns FALSE. If input is FALSE, this returns TRUE.
236Review of ConceptsCreating a Variable in ScratchClick on the “Variable” category.Then click on the “Create variable...” button.Name your variable.
237Review 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
238The ProblemHow can we create a car which detects and avoids edges (clis)?
239Project 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 two motors to move the car. Use 2 Line Finders in front of the car pointed downwards to detect if there is an edge (cli). Steer away if there is a cli.
240Project 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.2x Motor - to move the car.1x Motor Controller - controls and drives the attached motors.2x Wheel - attach to motor.2x Line Finder - detect if there is an edge / cli.
241Project Worksheet - Answers3. What is a simple explanation of the logic for the solution?Use two Motors to move the car.Use 2 Line Finders in front of the car pointing downwards to detect edges (cli).Read the left Line Finder to see if there is ground ahead (no cli).Read the right Line Finder to see if there is a ground ahead (no cli).If there is ground in both Left and Right sides, proceed forward.If there is no ground on the Left and ground on the Right, turn right. (Right side is safe to drive on).If there is ground on the Left and no ground on the Right, turn left. (Left side is safe to drive on).If there is no ground in both Left and Right sides, stop car.
242Project Worksheet - Answers4. Create a ow chart of the solution.StartSet variable for motor speedRead and store left and rightLine Finder valuesIs both left and right sides safe (no cliff)?Is only the right side safe (no cliff)?Is only the left side safe (no cliff)?Otherwise, unsafeTurn off motors(stop car)Set motors tomove car forwardSet motors to turn car rightSet motors to turn car leftShort delayLoopforever.TrueTrueTrueFalseFalseFalse
243Project 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 a Line Finder to pin A0/A1.5.  Connect a Line Finder to pin A2/A3.6.  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
244Project Worksheet - Answers6. Congure blocks to relate to the ow chart.StartSet variable for motor speedRead and store left and rightLine Finder valuesIs both left and right sides safe (no cliff)?Is only the right side safe (no cliff)?Is only the left side safe (no cliff)?Otherwise, unsafeTurn off motors(stop car)Set motors tomove car forwardSet motors to turn car rightSet motors to turn car leftShort delayLoopforever.TrueTrueTrueFalseFalseFalse
245The Script Block LocatorLoop.Click Green Flag to activate script.Short delay before looping.(Create these variables rst in the variable tab.)Set the variable for the speed of the motors.Read and store the left Line Finder (pin A0) value.Read and store the right Line Finder (pin A2) value.Check if it is safe on both Left and Right sides.Check if there is a cli on Left side and safe on Right side.Check if it is safe on Left side and a cli on Right side.Otherwise both sides are unsure,set motors to stop car.Set motors to proceed forward.Set motors turn right.Set motors turn left.ControlEventsmCookieDataOperatorsArduino
246Click the green ag to activate the script.1. The car will automatically move forward if left and right sides are safe (no cli).2. The car will turn right if only the right side is safe.3. The car will turn left is only the left side is safe.4. The car will stop if both left and right sides are unsafe (cli).Left Line Finder (pin A0)Right Line Finder (pin A2)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).
247Create a StructureCreate a structure for the project using building blocks, paper, or other crafting materials.
248Project ChallengeThe car stops when the left and right sides are unsafe.What other options can the car makes in this situation?Implement it on your own.
249ReviewMotor 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.Wheel - attaches to the Motor.Line Finder - detects the reective surface or distance of an object.Analog Read block - returns the value of the reective surface from the Line Finder sensor.
250Expanding the ProjectResearchWrite down a way of expanding this project. Create it on your own.Research more about edge/cli detection. What things implement this feature? Why is it important for each of those things to have this feature?______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
251Line Finding Car 1MIX 4 - Project 11(Old Cards: MIX4B-07)
252Some of the earliest Automated Guided Vehicles (AGVs) were line following mobile robots. They might follow a visual line painted or embedded in the oor or ceiling or an electrical wire in the oor. Most of these robots operated a simple “keep the line in the center sensor” algorithm. They could not cir-cumnavigate obstacles; they just stopped and waited when something blocked their path.Source: https://en.wikipedia.org/wiki/Mobile_robot#Line-following_CarAbout Line Following Cars
253Review of ModulesUsageThe 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).Line FinderAnalog 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 Returned
254Review 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.
255Review 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.
256Review of ConceptsBooleansBooleans are a type of data, which can only either be TRUE or FALSE. Booleans are used in the condition checks on blocks such as the “If”, “If Else”, “Wait Until” blocks.Boolean OperatorsBoolean Operators enables performing operations on boolean types. It is useful for testing multiple conditions.Left Input Right Input ResultTrue True TrueTrue False FalseFalse True FalseFalse False FalseLeft Input Right Input ResultTrue True TrueTrue False TrueFalse True TrueFalse False FalseInput ResultTrue FalseFalse TrueAnd blockOr blockNot blockThis block returns TRUE, when both the inputs are TRUE. Otherwise, it returns FALSE.This block returns TRUE, when one of the input isTRUE. Otherwise, it returns FALSE.This block returns the opposite of the input. If in-put is TRUE, this returns FALSE. If input is FALSE, this returns TRUE.
257Review of ConceptsCreating a Variable in ScratchClick on the “Variable” category.Then click on the “Create variable...” button.Name your variable.
258Review 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
259The ProblemHow can we create a car which follows a black line (track)?
260Project 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 two motors to move the car. Use Two Line Finders pointed downward to detect the black line. Adjust ac-cordingly to stay on the black line.
261Project Worksheet - Answers2. List all the parts needed for the solution. What is the purpose of each part?Project 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.2x Motor - to move the car.1x Motor Controller - controls and drives the attached motors.2x Wheel - attach to motor.2x Line Finder - to detect the black line.
262Project Worksheet - Answers3. What is a simple explanation of the logic for the solution?Use two Motors to move the car.Use 2 Line Finders pointed downward to detect the black line.When the both Line Finders do not detect the black line, proceed forward.When the left Line Finder detects the black line, steer left.When the right Line Finder detects the black line, steer right.*Note: The Line Finders must be spaced apart slightly more than the width of the black line (as illustrated).Left Line FinderRight Line FinderBlack line
263Project Worksheet - Answers4. Create a ow chart of the solution.StartSet variable for motor speedRead and store if left and rightLine Finder detects a lineIs both left and right sides not detecting a line?Is only the left detecting a line?Is only the rightdetecting a line?Otherwise, on the lineturn off motors(stop car)Set motors tomove car forwardSet motors to turn car leftSet motors to turn car rightShort delayLoopforever.TrueTrueTrueFalseFalseFalse
264Project 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 a Line Finder to pin A0/A1.5.  Connect a Line Finder to pin A2/A3.6.  Insert one end of the USB cable into mCenter+ and connect the other to a computer.D2/D3D8/D9I2C A2/A3I2CD4/D5A6/A7A0/A1I2CD6/D7D2/D3D8/D9I2C A2/A3I2CD4/D5A6/A7A0/A1I2CD6/D7
265Project Worksheet - Answers6. Congure blocks to relate to the ow chart.StartSet variable for motor speedRead and store if left and rightLine Finder detects a lineIs both left and right sides not detecting a line?Is only the left detecting a line?Is only the rightdetecting a line?Otherwise, on the lineturn off motors(stop car)Set motors tomove car forwardSet motors to turn car leftSet motors to turn car rightShort delayLoopforever.TrueTrueTrueFalseFalseFalse
266The Script Block LocatorLoop.Click Green Flag to activate script.Short delay before looping.(Create these variables rst in the variable tab.)Set the variable for the speed of the motors.Read and store Left side if detects a black line.0 (false) = detecting line. 1 (true) = not detecting line.Read and store Right side if detects a black line.0 (false) = detecting line. 1 (true) = not detecting line.Check if not detecting line on both sides.Set motors to move car forward.Otherwise car is on the black line,Set motors to o (stop the car).Set motors to turn car right.Set motors to turn car left.Check if detecting line on left side.Check if detecting line on right side.ControlEventsmCookieDataOperatorsArduino
267Click the green ag to activate the script.1. Create a straight line with black tape.2. Make sure your Line Finders are spaced apart SLIGHTLY larger than the width of the black tape.3. Place the car on the black tape. The car will trace the black tape.Left Line Finder (pin A0)Right Line Finder (pin A1)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).
268Create a StructureCreate a structure for the project using building blocks, paper, or other crafting materials.
269Project ChallengeThe car stops if it detects the line on both Line Finders (left and right). What is another solution for this scenario?Implement it on your own.
270ReviewMotor 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.Wheel - attaches to the Motor.Line Finder - detects the reective surface or distance of an object.Analog Read block - returns the value of the reective surface from the Line Finder sensor.
271Expanding the ProjectResearchWrite down a way of expanding this project. Create it on your own.Research more about Line Finding cars.What are some other features and advancements have been added to this type of car?______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
272Line Finding Car 2MIX 4 - Project 12(Old Cards: MIX4B-08)
273Some of the earliest Automated Guided Vehicles (AGVs) were line following mobile robots. They might follow a visual line painted or embedded in the oor or ceiling or an electrical wire in the oor. Most of these robots operated a simple “keep the line in the center sensor” algorithm. They could not cir-cumnavigate obstacles; they just stopped and waited when something blocked their path.Source: https://en.wikipedia.org/wiki/Mobile_robot#Line-following_CarAbout Line Following Cars
274Review of ModulesUsageThe 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).Line FinderAnalog 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 Returned
275Review 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
276Review 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.
277Review 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.
278Review of ConceptsBooleansBooleans are a type of data, which can only either be TRUE or FALSE. Booleans are used in the condition checks on blocks such as the “If”, “If Else”, “Wait Until” blocks.Boolean OperatorsBoolean Operators enables performing operations on boolean types. It is useful for testing multiple conditions.Left Input Right Input ResultTrue True TrueTrue False FalseFalse True FalseFalse False FalseLeft Input Right Input ResultTrue True TrueTrue False TrueFalse True TrueFalse False FalseInput ResultTrue FalseFalse TrueAnd blockOr blockNot blockThis block returns TRUE, when both the inputs are TRUE. Otherwise, it returns FALSE.This block returns TRUE, when one of the input isTRUE. Otherwise, it returns FALSE.This block returns the opposite of the input. If in-put is TRUE, this returns FALSE. If input is FALSE, this returns TRUE.
279Review of ConceptsCreating a Variable in ScratchClick on the “Variable” category.Then click on the “Create variable...” button.Name your variable.
280Review 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
281The ProblemHow can enhance the line following robot to increase its accuracy?
282Project 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.Add two additional Line Finders to increase the line detection accuracy.
283Project 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.6x 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 - to move the car.1x Motor Controller - controls and drives the attached motors.2x Wheel - attach to motor.4x Line Finder - to detect the black line.1x Potentiometer - to adjust speed of the truck.
284Project Worksheet - Answers2. List all the parts needed for the solution. What is the purpose of each part? (Continued)1x IO Splitter - to connect two sensors/trinkets to a single connector.
285Project Worksheet - Answers3. What is a simple explanation of the logic for the solution?Use two Motors to move the car.Use 4 Line Finders pointed downward to detect the black line.Use a Potentiometer to congure the Line Finder threshold for registering a black line.Leftmost Line Finder is labeled S0, Left middle is S1, Right middle is S2, Rightmost is S3.A. Only Leftmost detects line - turn sharply to the left to get back on line.B. Only Leftmost and Left middle detects line - turn slightly to left to get back on line.C. Only Left middle and Right middle detects line - already on the line, go straight.D. Only Right middle and Rightmost detects line - turn slightly to the right to get back on line.E. Only Rightmost detects line - turn sharply to the right to get back on line. A B C ED
286Project Worksheet - Answers4. Create a ow chart of the solution.StartSet variable for motor speedRead and store if the 5Line Finders detects a lineLoopforever.Is condition A present?Is condition B present?Is condition C present?Is condition D present?Is condition E present?Read and store Potentiometervalue for line thresholdSet motors tomove car forwardSet motors to sharply turn leftSet motors to sharply turn rightSet motors to slight turn leftSet motors to slight turn rightOtherwise, unknown conditionturn off motors(stop car)Short delayTrueTrueTrueTrueTrueFalseFalseFalseFalseFalse
287Project 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 a Potentiometer to pin A6/A75.  Connect two Line Finders to an IO Splitter. Connect the IO Splitter to pin A0/A1.6.  Connect two Line Finders to an IO Splitter. Connect the IO Splitter to pin A2/A3.7.  Insert one end of the USB cable into mCenter+ and connect the other to a computer.D2/D3D8/D9I2C A2/A3I2CD4/D5A6/A7I2CD6/D7A0/A1IN BIN B
288Project Worksheet - Answers6. Congure blocks to relate to the ow chart.StartSet variable for motor speedRead and store if the 5Line Finders detects a lineLoopforever.Is condition A present?Is condition B present?Is condition C present?Is condition D present?Is condition E present?Read and store Potentiometervalue for line thresholdSet motors tomove car forwardSet motors to sharply turn leftSet motors to sharply turn rightSet motors to slight turn leftSet motors to slight turn rightOtherwise, unknown conditionturn off motors(stop car)Short delayTrueTrueTrueTrueTrueFalseFalseFalseFalseFalse
289The Script Block LocatorLoop.Click Green Flag to activate script.Short delay before looping.(Create these variables rst in the variable tab.)Set the variable for the speed of the motors.Read and store Potentiometer (pin A6) for line threshold.Read and store Line Finder values.Check for condition A.Set motors to turn sharply to the left.Check for condition B.Set motors to turn slightly to the left.Check for condition C.Set motors to move quickly forward.Check for condition D.Set motors to turn sharply to the right.Check for condition E.Set motors to turn slightly to the right.Unknown condition,turn motors o (stop car).ControlEventsmCookieDataOperatorsArduino“1” represents detecting line.“0” represents” no line detected.
290Click the green ag to activate the script.1. Create a straight line with black tape.2. Make sure the Line Finders are side by side with the correct positions. The two middle Line Finders should be detecting the black tape.3. Place the car on the black tape. The car will trace the black tape.Line Finder (pin A0)Line Finder (pin A1)Line Finder (pin A2)Line Finder (pin A3) Adjust the sensitivity of line detection by adjusting 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: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).
291Create a StructureCreate a structure for the project using building blocks, paper, or other crafting materials.
292Project ChallengeAdd a Color LED to the project.Have it indicate the current condition detected (A~E).Modify the behavior to your liking when it reaches the unknown conditiion.
293ReviewMotor 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.Wheel - attaches to the Motor.Line Finder - detects the reective surface or distance of an object.Analog Read block - returns the value of the reective surface from the Line Finder sensor.
294Expanding the ProjectResearchWrite down a way of expanding this project. Create it on your own.Research new technologies for self driving vehicles. What kind of methods are used in these self-driving cars?______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
FCC WarningThis device complies with part 15 of the FCC Rules. Operation is subject to the following two conditions: (1) This device may not cause harmful interference, and (2) this device must accept any interference received, including interference that may cause undesired operation.Any Changes or modifications not expressly approved by the party responsible for compliance could void the user's authority to operate the equipment. This equipment has been tested and found to comply with the limits for a Class B digital device, pursuant to part 15 of the FCC Rules. These limits are designed to provide reasonable protection against harmful interference in a residential installation. This equipment generates uses and can radiate radio frequency energy and, if not installed and used in accordance with the instructions, may cause harmful interference to radio communications. However, there is no guarantee that interference will not occur in a particular installation. If this equipment does cause harmful interference to radio or television reception, which can be determined by turning the equipment off and on, the user is encouraged to try to correct the interference by one or more of the following measures: -Reorient or relocate the receiving antenna. -Increase the separation between the equipment and receiver. -Connect the equipment into an outlet on a circuit different from that to which the receiver is connected. -Consult the dealer or an experienced radio/TV technician for help.The device has been evaluated to meet general RF exposure requirement. The device can be used in portable exposure condition without restriction.295

Navigation menu