Skip to content
Snippets Groups Projects
Commit 8cd0bb33 authored by Bengt Ragnemalm's avatar Bengt Ragnemalm
Browse files

Moved UsbReceive.ino

parent 4967db6a
No related branches found
No related tags found
No related merge requests found
/*************************************************************************
* Code that reads values sent from python through serial
************************************************************************/
#include <Wire.h> // For I2C communication with sensor
#include <Wireling.h> // For interfacing with Wirelings
// Make Serial Monitor compatible for all TinyCircuits processors
#if defined(ARDUINO_ARCH_AVR)
#define SerialMonitorInterface Serial
#elif defined(ARDUINO_ARCH_SAMD)
#define SerialMonitorInterface SerialUSB
#endif
void setup() {
SerialMonitorInterface.begin(115200);
Wire.begin();
// Initialize Wireling
Wireling.begin();
Wireling.selectPort(0);
analogWriteResolution(10); //Change the DAC resolution to 10-bits
analogWrite(A0, 0); // Initialize Dac to Zero
}
void loop() {
int output;
//static float x = 270; // Current degrees for sine wave (initially 270 so that
// the sine wave is initially zero).
// output = (int) (512.0 * sin(0.017453 * x) + 512); // Sine Wave
if (SerialMonitorInterface.available()> -1) {
output = SerialMonitorInterface.parseInt();
analogWrite(A0, output);
}// end if serial available
//analogWrite(A0, output); // Write the analog output to A0
//SerialMonitorInterface.print(output);
//SerialMonitorInterface.println();
/*
* Increment Degrees for the Next Wave Point
*
* To utilize the entire resolution of the 10-bit DAC, at least 1024
* values must be used between 0 and 360 degrees. Therefore, a step
* value greater than 360/1024 will not utilize the entier resolution
* of the DAC.
*/
//x += 0.35;
//if(x>=360.0) x -= 360.0;
//delay(1);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment