I have a sketch that sends OSC messages using a ESP8266, potentiometer and the OSCBundle.h It works as expected and I am able to monitor the incoming messages on a PC. I need to map the value of the potentiometer which I have done successfully in past projects. I'm having problems wrapping my head around how to do it in this case. I tried implementing the map value a few different ways and always end up creating code errors that i end up chase down a rabbit hole. Could I please get some help,
I would like to understand how to map the init32_t value from 0-1024 to a range of my choosing say the typical 0-255 or 0-127. the way this line is structured and how to implement the map function is confusing me.
bndl.add("/Volume/0").add((uint32_t)analogRead(0));
Thanks You
the entire code is here
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <SPI.h>
#include <OSCBundle.h>
char ssid[] = "ssid";
char pass[] = "pass";
WiFiUDP Udp;
const IPAddress outIp(10,8,1,214);
const unsigned int outPort = 9999;
const unsigned int localPort = 8888;
void setup()
{
Serial.begin(115200);
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED)
delay(1000);
Udp.begin(localPort);
Serial.println(WiFi.localIP());
Serial.println(Udp.localPort());
}
void loop()
{
OSCBundle bndl;
bndl.add("/Volume/0").add((uint32_t)analogRead(0));
Udp.beginPacket(outIp, outPort);
bndl.send(Udp);
Udp.endPacket();
bndl.empty();
delay(10);
}