Here I did copy file and pace it. Or need to copy different way ?
sketch_dec27a.ino (1.4 KB)
Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'
Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination
https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum
Please post your sketch, using code tags when you do
Posting your code using code tags prevents parts of it being interpreted as HTML coding and makes it easier to copy for examination
In my experience the easiest way to tidy up the code and add the code tags is as follows
Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.
If you want to post code to the forum then
void setup() {
(injectorBank1, OUTPUT);
pinMode(injectorBank2, OUTPUT);
// Setup interrupt on pin 2 (external interrupt 0) for crankshaft sensor signal
attachInterrupt(digitalPinToInterrupt(2), crankshaftISR, RISING);
Serial.begin(9600); // For debugging // put your setup code here, to run once:
}
void loop() {
if (syncDetected) {
syncDetected = false; // Reset sync flag
// FIRST REVOLUTION: Bank 1
delayMicroseconds(1333 * 55); // Delay to 330° (55 teeth from missing teeth)
digitalWrite(injectorBank1, HIGH); // Start injection for Bank 1
delay(injectionTime); // Injection duration
digitalWrite(injectorBank1, LOW); // Stop injection for Bank 1
// SECOND REVOLUTION: Bank 2
delayMicroseconds(1333 * 60); // Wait for 1 full revolution (60 teeth)
delayMicroseconds(1333 * 55); // Delay to 330° for Bank 2
digitalWrite(injectorBank2, HIGH); // Start injection for Bank 2
delay(injectionTime); // Injection duration
digitalWrite(injectorBank2, LOW); //Stop injection for Bank 2
}
}
// Interrupt Service Routine (ISR) for crankshaft signal
void crankshaftISR() {
toothCount++;
if (toothCount >= syncTooth) { // Detect missing teeth (sync point)
toothCount = 0; // Reset tooth count
syncDetected = true; // Set sync flag
} // put your main code here, to run repeatedly:
}
No
Not just select all and paste. Please try again
What problem do you have with the sketch ?
I do not know what is the problem with the sketch
Does it compile ?
If it compiles, what should it do and what does it actually do ?
If it does not compile then please post the full error message
In post number 4 is the code. How to do compile ? I do not see any error messages.
void setup() {
(injectorBank1, OUTPUT);
pinMode(injectorBank2, OUTPUT);
// Setup interrupt on pin 2 (external interrupt 0) for crankshaft sensor signal
attachInterrupt(digitalPinToInterrupt(2), crankshaftISR, RISING);
Serial.begin(9600); // For debugging // put your setup code here, to run once:
}
void loop() {
if (syncDetected) {
syncDetected = false; // Reset sync flag
// FIRST REVOLUTION: Bank 1
delayMicroseconds(1333 * 55); // Delay to 330° (55 teeth from missing teeth)
digitalWrite(injectorBank1, HIGH); // Start injection for Bank 1
delay(injectionTime); // Injection duration
digitalWrite(injectorBank1, LOW); // Stop injection for Bank 1
// SECOND REVOLUTION: Bank 2
delayMicroseconds(1333 * 60); // Wait for 1 full revolution (60 teeth)
delayMicroseconds(1333 * 55); // Delay to 330° for Bank 2
digitalWrite(injectorBank2, HIGH); // Start injection for Bank 2
delay(injectionTime); // Injection duration
digitalWrite(injectorBank2, LOW); //Stop injection for Bank 2
}
}
// Interrupt Service Routine (ISR) for crankshaft signal
void crankshaftISR() {
toothCount++;
if (toothCount >= syncTooth) { // Detect missing teeth (sync point)
toothCount = 0; // Reset tooth count
syncDetected = true; // Set sync flag
} // put your main code here, to run repeatedly:
}
If you have not tried to compile it then there will be no error messages but I am afraid that the code in post #4 is nonsense. Where did you get it from ?
I did copy for forum and pace it in forum
what next ?
I did get this code from GPT by describing how the Arduino uno should output signal
Have you got the Arduino IDE installed ?
If I have not tried to compile it then there will be no error messages. How to compile ?
Yes Arduino IDE is installed
Which version ?
Arduino IDE 2.3.4
Which Arduino board do you have ?
Does your PC create a COM port when you plug it in ?
Have you selected the correct board and COM port in the IDE ?
What is your native language ?
I do not have Arduino board yet.
Which one will you be getting ?