This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
docs:blox:examples-inputs-events [2024/08/20 12:42] admin |
docs:blox:examples-inputs-events [2024/08/26 17:48] (current) admin |
||
|---|---|---|---|
| Line 7: | Line 7: | ||
| ===== 6.3.1 Analog Sensors ===== | ===== 6.3.1 Analog Sensors ===== | ||
| - | Analog sensors measure values that can vary continuously within a range. For example, a temperature sensor might provide a value anywhere between 0°C and 100°C. | + | Analog sensors measure values that can vary continuously within a range. |
| - | The value from an analog sensor is typically represented as a changing voltage, which your microcontroller | + | |
| + | For most simple sensors, the value from an analog sensor is typically represented as a changing voltage, which your BLOX converts to a digital number | ||
| + | |||
| + | Some more advanced sensors uses I2C or SPI to communicate and provides a more direct value like a temperature or distance in actual units. | ||
| You usually respond to analog sensor readings by setting thresholds. For instance, if the temperature exceeds 30°C, you might trigger a fan to turn on, and if it drops below 30°C, the fan stays off. | You usually respond to analog sensor readings by setting thresholds. For instance, if the temperature exceeds 30°C, you might trigger a fan to turn on, and if it drops below 30°C, the fan stays off. | ||
| + | |||
| This approach allows for more nuanced control based on the varying data the sensor provides. | This approach allows for more nuanced control based on the varying data the sensor provides. | ||
| + | |||
| + | {{: | ||
| ---- | ---- | ||
| Line 17: | Line 24: | ||
| Digital sensors work like a simple switch, offering just two possible states: on or off, triggered or idle. | Digital sensors work like a simple switch, offering just two possible states: on or off, triggered or idle. | ||
| - | For example, a motion sensor might detect movement (triggered) or no movement (idle). | + | |
| - | Since digital sensors only have these two states, your code simply checks whether the sensor is triggered or not and reacts accordingly. | + | For example, a motion sensor might detect movement (on) or no movement (off). |
| + | |||
| + | Since digital sensors only have these two states, your program | ||
| This type of sensor is often used for straightforward tasks like detecting the presence of an object or whether a button has been pressed. | This type of sensor is often used for straightforward tasks like detecting the presence of an object or whether a button has been pressed. | ||
| + | |||
| + | {{: | ||
| + | |||
| + | ---- | ||
| + | |||
| + | ===== 6.3.2 PS2 Gamepad as an Input Device ===== | ||
| + | |||
| + | BLOX supports using a PS2 gamepad as an input device | ||
| + | |||
| + | {{: | ||
| + | |||
| + | {{: | ||
| + | |||
| + | ---- | ||
| + | |||