-1
void setup() {
  // put your setup code here, to run once:
pinMode (9, OUTPUT) ;
pinMode (10, OUTPUT) ;
TCCR1A = 0;
TCCR1B = 0
TCCR1A |= (1<<WGM11) | (1<<COM1A1) | (1<<COM1B1) ; //non-inverting (error msg)
TCCR1B |= (1<<CS10) | (1<<WGM12) | (1<<WGM13) ; //prescaler 1,}

void loop() {
  // put your main code here, to run repeatedly:
ICR1 = map(analogRead(A1), 0, 1023, 0, 255);
OCR1A = map(analogRead(A0), 0, 1023, 0, ICR1);
}
  • List item

problem of uploading this sketch to arduino uno. anyone can heip.


cannot upload : expression cannot be used as a function

0

There is a semicolon ; missing after TCCR1B = 0

Second problem is that there is a missing } you actually left it in the comment here //prescaler 1,} separate it to two lines

//prescaler 1,
}

Please invest some time in learning basics of C++. It's pretty fun, and surprisingly easy.

| improve this answer | |
  • thank you filip. problem solve. 2nd problem come up. a function definition is not allowed here before '{' at void loop () { line. pls help. – lee Oct 17 '19 at 15:23
  • thank you filip. you are really helpful. – lee Oct 17 '19 at 15:30
0

This code, at least, compiles OK. I'm not sure what it's going to do on an Arduino.

void setup() {

  pinMode (9, OUTPUT);
  pinMode (10, OUTPUT);
  TCCR1A = 0;
  TCCR1B = 0;
  TCCR1A |= (1 << WGM11) | (1 << COM1A1) | (1 << COM1B1); //non-inverting (error msg)
  TCCR1B |= (1 << CS10) | (1 << WGM12) | (1 << WGM13); //prescaler 1,

}

void loop() {

  ICR1 = map(analogRead(A1), 0, 1023, 0, 255);
  OCR1A = map(analogRead(A0), 0, 1023, 0, ICR1);

}
| improve this answer | |
-2

Answer before updating your question:

The first line is not legel, it ends with

TCCR1A |= (1<

Than you start a new function with

void loop()

Also align your code by selecting it and press ctlr-k

UPDATE

After changing your question/code:

In this line:

TCCR1B |= (1<<CS10) | (1<<WGM12) | (1<<WGM13) ; //prescaler 1,}TCCR1B |= //prescaler 1,}

You have a comment (//), however, the code behind it is not executed, including the ending bracket } which closes the setup function.

Thus if you move the bracket } to the next new line, the function is closed according to the C(++) grammar.

(The missing colon is already mentioned by others).

| improve this answer | |
  • sorry i still don't understand. pls explain a bit more – lee Oct 17 '19 at 15:03
  • I updated the question ... for the downvoters: the question was changed after my initial answer which was correct for the previously code shown. – Michel Keijzers Oct 18 '19 at 8:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.