Hi
I want to serial plotter follow the blinking, on serial plotter I am looking for rectangular pulses 0/1 but I have two continuous lines the first one = 1,the second line is = 0
/*
Blink
Turns an LED on for one second, then off for one second, repeatedly.
Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
the correct LED pin independent of which board is used.
If you want to know what pin the on-board LED is connected to on your Arduino
model, check the Technical Specs of your board at:
https://www.arduino.cc/en/Main/Products
modified 8 May 2014
by Scott Fitzgerald
modified 2 Sep 2016
by Arturo Guadalupi
modified 8 Sep 2016
by Colby Newman
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/Blink
*/
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(PC13, OUTPUT);
Serial.begin(115200);
}
// the loop function runs over and over again forever
void loop() {
Serial.print(" PC13a = ");
//Serial.println(PC13);
digitalWrite(PC13, 1);
Serial.print(1);// turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(PC13, 0); // turn the LED off by making the voltage LOW
delay(1000);
Serial.print(" PC13b = ");
Serial.println(0);
}
What Arduino are you using? When I try to compile for Arduino UNO i get:
sketch_jul17a.ino: In function 'void setup()':
sketch_jul17a:29:11: error: 'PC13' was not declared in this scope
pinMode(PC13, OUTPUT);
^~~~
sketch_jul17a.ino: In function 'void loop()':
sketch_jul17a:38:16: error: 'PC13' was not declared in this scope
digitalWrite(PC13, 1);
^~~~
After changing to LED_BUILTIN I get Serial Monitor output:
The Serial Plotter shows alternating 0 and 1 values just as you would expect. The horizontal axis of Serial Plotter is 500 samples, not periods of time. If you want, for example, each pulse to take 100 samples, you have to send 50 samples each time the output level changes.
your sketch prints 1 then waits for 2 seconds prints 0 and immediately 1 again, so it is consistent with your output on plotter, the led on the other hand blinks every second. Re-examine your code
You're right. My mistake. You print both values on the same line so they are treated as two separate values to be plotted. One that is always 0 and one that is always 1.
If you want Serial Plotter to act like an oscilloscope you have to to decide how much time you want the 500 samples to represent. Let's say 10 seconds. That's 50 samples per second or one sample every 20 millisecond:
boolean CurrentState = false;
void setup()
{
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(115200);
while (!Serial) {}
Serial.println("CurrentState"); // Graph label.
}
void doBlink()
{
static unsigned long blinkTimer = 0;
unsigned long currentTime = millis();
if (currentTime - blinkTimer >= 1000)
{
blinkTimer = currentTime;
CurrentState = !CurrentState;
digitalWrite(LED_BUILTIN, CurrentState);
}
}
void doGraph()
{
static unsigned long sampleTimer = 0;
unsigned long currentTime = millis();
if (currentTime - sampleTimer >= 20)
{
sampleTimer = currentTime;
Serial.println(CurrentState);
}
}
void loop()
{
doBlink();
doGraph();
}
Something is wrong with Github, this is one of the examples, on serial plotter should be sine wave but I have only 3 straight lines
/*
===========================================================================================
Example used in Quick-Start
-------------------------------------------------------------------------------------------
Plotter
v2.4.1
https://github.com/devinaconley/arduino-plotter
by Devin Conley
===========================================================================================
*/
#include "Plotter.h"
double x;
Plotter p;
void setup()
{
p.Begin();
p.AddTimeGraph( "Some title of a graph", 1500, "label for x", x );
}
void loop() {
x = 10*sin( 2.0*PI*( millis() / 5000.0 ) );
p.Plot(); // usually called within loop()
}
*I installed but can't use it * # # A fatal error has been detected by the Java Runtime Environment: # # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000007110b5db, pid=5080, tid=0x00000000000008c0 # # JRE version: Java(TM) SE Runtime Environment (8.0_333-b02) (build 1.8.0_333-b02) # Java VM: Java HotSpot(TM) 64-Bit Server VM (25.333-b02 mixed mode windows-amd64 compressed oops) # Problematic frame: # C [jSSC-2.8.dll+0xb5db] # # Failed to write core dump. Minidumps are not enabled by default on client versions of Windows # # If you would like to submit a bug report, please visit: # Crash Report # The crash happened outside the Java Virtual Machine in native code. # See problematic frame for where to report the bug. #