EEPROM and mx1508 driver

您所在的位置:网站首页 mx1508l EEPROM and mx1508 driver

EEPROM and mx1508 driver

#EEPROM and mx1508 driver| 来源: 网络整理| 查看: 265

The limit switch shouldn't really make the motor change direction. The job of the limit switch in this scenario is to let the software know that an object (in this case the barrier) has reached a predetermined position.

Your project may benefit from a simple state machine such that:

State 0: UNKNOWN - the barrier is not fully up or fully down (usually at power on) State 1: DOWN - the down limit switch is activated State 2: GOING_UP - barrier is moving up & waiting for up limit switch to activate State 3: UP - the up limit switch is activated State 4: GOING_DOWN - barrier is moving down & waiting for the down limit switch to activate.

You can achieve this with a simple switch statement.

arduino.cc switch...case - Arduino Reference

The Arduino programming language Reference, organized into Functions, Variable and Constant, and Structure keywords.

Your touch button will then perform a different function depending on which state your barrier is in.

In state 1, touching the button moves the barrier to state 2 where you activate the motor to raise the barrier. In state 3, touching the button moves the barrier to state 4 where you activate the motor to lower the barrier.

In state 2, you look for the up limit switch and when it is activated, you stop the motor and move to state 3. Similarly in state 4, you look for the down limit switch and when it is activated, you stop the motor and move to state 1.



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3