Skip to main content

Auto Timed DC Motor

In this project, we build a timed DC Motor fan using a DC Motor and a L293D motor driver IC.

Circuit

DC motor auto

Components

  • 1 Smowboard Think Mini
  • 1 L293D IC
  • 1 DC Motor
  • 1 Fan propeller
  • 4 male-to-male jumper wires
  • 4 male-to-female jumper wires

In this circuit, we use the L293D IC to control the DC Motor. We connect the pin number 1 of the IC which is the ENABLE pin to the Vin pin of Smowboard. We also connect the pin number 8 of the IC which is Vcc2 pin and the pin number 16 of the IC which is Vcc1 pin to the Vin pin of Smowboard. The IC is grounded by connecting its pin number 4 which is the ground pin to the ground of Smowboard. The pin number 2 of the IC which is the INPUT1 pin is connected to the pin number 4 of Smowboard. The INPUT2 pin of the IC which is pin number 7 is connected to the pin number 2 of Smowboard. These two input pins are controlled by the Smowboard. We connect the pin number 3 of IC which is the OUTPUT1 pin and pin number 6 of the IC which is the OUTPUT2 pin to the DC Motor. We connect a fan propeller to the shaft of DC Motor which works as a fan.

The Smowboard controls the input pins of the IC. It can decide the direction of the rotation of motor as well as whether the motor will be ON or OFF. The motor driver IC recieves the signals from the Smowboard and transmits them to the motor. Thus, the motor will be turned ON and OFF and rotate in a clockwise or anti-clockwise manner depending on the signal recieved from the Smowboard.

Flow

DC Motor auto flow


[{"id":"ffe9ca2e.0695d8","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"34f46254.bd828e","type":"common/on interval","z":"ffe9ca2e.0695d8","config_props":{"name":"","interval":"0.01"},"outputProps":{},"dependency_set":{},"x":210,"y":140,"wires":[["640f4564.db93cc"]]},{"id":"640f4564.db93cc","type":"smow_motor/dc motor","z":"ffe9ca2e.0695d8","config_props":{"name":"","motor":"c6a4c200.8639a","on_off":"1","dir":"0"},"outputProps":{},"dependency_set":{"dir_visibility":true},"x":440,"y":140,"wires":[["ae75df48.2dfd8"]]},{"id":"3a2fda53.a83dd6","type":"smow_motor/dc motor","z":"ffe9ca2e.0695d8","config_props":{"name":"","motor":"c6a4c200.8639a","on_off":"1","dir":"0"},"outputProps":{},"dependency_set":{"dir_visibility":true},"x":440,"y":240,"wires":[["9db17a80.7da938"]]},{"id":"7e52864d.ec9148","type":"smow_motor/dc motor","z":"ffe9ca2e.0695d8","config_props":{"name":"","motor":"c6a4c200.8639a","on_off":"0","dir":"0"},"outputProps":{},"dependency_set":{"dir_visibility":false},"x":440,"y":340,"wires":[["8efcb347.b034"]]},{"id":"ae75df48.2dfd8","type":"common/delay","z":"ffe9ca2e.0695d8","config_props":{"name":"","period":"3"},"outputProps":{},"dependency_set":{},"x":680,"y":140,"wires":[["3a2fda53.a83dd6"]]},{"id":"9db17a80.7da938","type":"common/delay","z":"ffe9ca2e.0695d8","config_props":{"name":"","period":"3"},"outputProps":{},"dependency_set":{},"x":680,"y":240,"wires":[["7e52864d.ec9148"]]},{"id":"8efcb347.b034","type":"common/delay","z":"ffe9ca2e.0695d8","config_props":{"name":"","period":"2"},"outputProps":{},"dependency_set":{},"x":680,"y":340,"wires":[[]]},{"id":"c6a4c200.8639a","type":"smow_motor/dc motor config","z":"","config_props":{"name":"","motor_mode":"1","pin1":"2","pin2":"4"},"outputProps":{},"dependency_set":{"mode_2_pin":true}}]

To import this code to the Studio, copy it and paste it into the import nodes dialog box in the import section.

Lets understand the code,

  • The flow starts with an on interval node. All next nodes connected to it get triggered repeatedly after the specified interval of time.
  • Double click on the node to change its properties.
  • We set the time interval of the on-interval node to 0.01 seconds.
  • We use the dc motor node to control the DC Motor. Configure the node by clicking on the pencil icon on the 'motor' property of the node. Set the 'Motor Mode' to 2 pin (direction control). We have connected the input pins of the IC to the pin number 2 and 4 of the Smowboard so set the 'pin 1' value as 2 and 'pin 2' value as 4.
  • We then click on Add and done to complete the configuration.
  • Set the 'Switch' property of the node to 'Turn ON'. This will keep the fan ON. Set the 'direction' property as clockwise to rotate the fan in clockwise direction.
  • We now connect a delay node to add a delay of 3 seconds before the next node, dc motor runs.
  • The fan keeps rotating in clockwise direction for this 3 seconds.
  • We add another dc motor node and set its 'direction' property to anticlockwise to rotate the fan in anticlockwise direction.
  • We add another delay of 3 seconds using the delay node. This adds a delay of 3 seconds before the next node, dc motor runs.
  • The fan continues to rotate in anticlockwise direction for this 3 seconds.
  • We now connect the third dc motor node and set its 'Motor Mode' property to Turn OFF. This will turn OFF the fan.
  • We end the flow with a delay node which adds a delay of 2 seconds. The flow doesn't restart before this nodes's activity (i.e delay) finishes.
  • The fan is remains OFF for this 2 seconds.
  • Now, we upload the code to the Smowboard using the upload button on the Studio.
  • We can see that our fan rotates in clockwise direction for 3 seconds and then in anticlockwise direction for 3 seconds and then eventually it turns OFF for 2 seconds.

Output

DC Motor auto flow


Learn Coding and Electronics easily using Smowcode.