Good Day everyone,
I am relatively new to the arduino and getting a hang of it.
I actually want to generate a sequence that is {0,0,0,1,1,1,0,0,0,0,1,1,0,0,1,0,1,0,1,0,1,1,0,0,1,1,0,1,0,1,0,0,1,0,1,0,1,0,1,0,1,1,0}
at 2 MHz.
I went through the reference and was able to use delayMicroseconds and digitalWrite but the problem I am facing is that it is not being genrated at 2 MHz. the frequency sepatatin between two adjacent pulses is variable as well as not more than 250 KHz at any place.
the code I am using is:
int i;
int Myarray[43] = {0,0,0,1,1,1,0,0,0,0,1,1,0,0,1,0,1,0,1,0,1,1,0,0,1,1,0,1,0,1,0,0,1,0,1,0,1,0,1,0,1,1,0};
// the setup function runs once when you press reset or power the board
void setup() {
pinMode(13, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
for (i=0;i<100;i=i+1){
digitalWrite(13, LOW); //preceded by zeros
delayMicroseconds(1);}
for (i=0;i<43;i=i+1){
digitalWrite(13, Myarray*); //the required bit sequence*
- delayMicroseconds(1);}*
}
Can anyone point out the error and help me out?
I would be highly grateful
Thanks in advance
![]()