GY-63_MS5611/libraries/map2colour/examples/map2colour_demo01/map2colour_demo01.ino

54 lines
970 B
Arduino
Raw Normal View History

2021-12-04 15:32:57 -05:00
//
// FILE: map2colour_demo01.ino
// AUTHOR: Rob Tillaart
// PURPOSE: map2colour demo
// URL: https://github.com/RobTillaart/map2colour
#include "Arduino.h"
#include "map2colour.h"
2021-12-09 09:05:02 -05:00
2021-12-04 15:32:57 -05:00
map2colour mc;
2022-10-20 05:58:00 -04:00
// should be in increasing order
2021-12-04 15:32:57 -05:00
float values[7] = { 0, 32, 64, 128, 256, 512, 1024 };
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
2022-10-20 05:58:00 -04:00
Serial.print("MAP2COLOUR_LIB_VERSION: ");
Serial.println(MAP2COLOUR_LIB_VERSION);
Serial.println();
2021-12-04 15:32:57 -05:00
2022-10-20 05:58:00 -04:00
// load the values array
2021-12-04 15:32:57 -05:00
mc.begin(values);
2022-10-20 05:58:00 -04:00
// show the interpolating
2021-12-04 15:32:57 -05:00
for (float i = 0; i < 1024; i += 10)
{
uint32_t rgb = mc.map2RGB(i);
Serial.print(i);
Serial.print("\t");
Serial.println(rgb, HEX);
}
2021-12-09 09:05:02 -05:00
Serial.println();
2021-12-04 15:32:57 -05:00
}
void loop()
{
2022-10-20 05:58:00 -04:00
int x = analogRead(0); // UNO returns between 0..1023; adapt if needed.
2021-12-04 15:32:57 -05:00
uint32_t rgb = mc.map2RGB(x);
Serial.print(x);
Serial.print("\t");
Serial.println(rgb, HEX);
delay(100);
}
// -- END OF FILE --
2022-10-20 05:58:00 -04:00