We are trying to convert the measure of time from milliseconds to nanoseconds. I am unsure how to use the millisecond and time conversion of 62.5 to make it in nanoseconds.
`//pin connected to the LED
const int ledPin = 13;
void setup() {
// put your setup code here, to run once:
pinMode(ledPin, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
// Turn the LED on
digitalWrite(ledPin, HIGH);
delay(.2);
//turn the LED off
digitalWrite(ledPin, LOW);
delay (2);
}
`
If you really need a 62.5 nanosecond granularity then you will not be able to use the Arduino Core (no digitalWrite, no delay, timer 0 interrupt turned off).
The time conversion from milliseconds to nanoseconds is 1,000,000
The conversion from nanoseconds to clock cycles involves the 62.5
The delay function only takes integral values. You can't use a decimal number.
delayMicroseconds(200);
will do what it looks like you want in that line.
It isn't really clear what you actually want to do. If you're trying to toggle a pin very fast with some nanosecond resolution then use a PWM timer. That's what they're built for.
wouldnt delayMicroseconds(200) be 0.2 nanoseconds which the board cannot do numerical values that aren't integers I believe. What would be a way around this?
You might need to work on your math before you go too far coding this. 200 microseconds is 200,000 nanoseconds.
That's not what you were told. What we said was that the delay function only takes integers. The delayMicroseconds function also only takes integers. 200 is an integer. There is no decimal on 200.