This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:examples:sensor:color [2012/06/07 00:06] – raivo.sell | en:examples:sensor:color [2020/07/20 12:00] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Color sensor ====== | ====== Color sensor ====== | ||
| - | //Necessary knowledge: [HW] [[en: | + | //Necessary knowledge: [HW] [[en: |
| ===== Theory ===== | ===== Theory ===== | ||
| Line 26: | Line 26: | ||
| Sensor outputs a voltage, proportional to all the light that it sees weighted by the curve on the figure. Therefore, when a subject is illuminated with a red LED only it will respond with a voltage proportional to the red component of the subjects color and similarly with blue and green. When there is ambient light mixed in with the LEDs illumination, | Sensor outputs a voltage, proportional to all the light that it sees weighted by the curve on the figure. Therefore, when a subject is illuminated with a red LED only it will respond with a voltage proportional to the red component of the subjects color and similarly with blue and green. When there is ambient light mixed in with the LEDs illumination, | ||
| - | ColorPAL sensor requires only three connections: | + | ColorPAL sensor requires only three connections: |
| + | |||
| + | [{{ : | ||
| + | |||
| + | Example code enabling to read the RGB values which is printed on the screen using hex format. Measurements with ColorPAL sensor will be made automatically. | ||
| <code c> | <code c> | ||
| Line 34: | Line 38: | ||
| #include < | #include < | ||
| - | // | ||
| // Determining USART interface. | // Determining USART interface. | ||
| - | // | ||
| usart port = USART(0); | usart port = USART(0); | ||
| - | // | + | // Main program |
| - | //MAIN | + | |
| - | // | + | |
| int main(void) | int main(void) | ||
| { | { | ||
| Line 99: | Line 99: | ||
| data[i-3] = c; | data[i-3] = c; | ||
| } | } | ||
| - | |||
| } | } | ||