B4R Question Change analog input resolution from 10 bit to 12 bit "MKR1010"

Åke Johansson Bravida

Member
Licensed User
The Due, Zero and MKR Family boards have 12-bit ADC capabilities that can be accessed by changing the resolution to 12.
This will return values from analogRead between 0 and 4095.
How do I enable this in B4R?

Thank you
Åke Artklo
 

Åke Johansson Bravida

Member
Licensed User
Hello again I try to use this code:
But I do something wrong i get error

b4r_main.cpp:35:23: error: expected constructor, destructor, or type conversion before '(' token
analogReadResolution(12);



Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
RunNative("analogReadResolution", Null)
analog_A0.Initialize(analog_A0.A0,analog_A0.MODE_INPUT) 'Tempsensor
End Sub


#if C
analogReadResolution(12);

#End if
 
Upvote 0

Åke Johansson Bravida

Member
Licensed User
No, I got this error.

C:\project\B4R\TJMQTT~1\Objects\bin\sketch\b4r_main.cpp: In function 'void Set_ADC_12bit(B4R::Object*)':
b4r_main.cpp:37:26: error: 'analogReadResolution' was not declared in this scope
analogReadResolution(12);
^
exit status 1

Any suggestion?
 
Upvote 0

thetahsk

Active Member
Licensed User
Longtime User
No, I got this error.

C:\project\B4R\TJMQTT~1\Objects\bin\sketch\b4r_main.cpp: In function 'void Set_ADC_12bit(B4R::Object*)':
b4r_main.cpp:37:26: error: 'analogReadResolution' was not declared in this scope
analogReadResolution(12);
^
exit status 1

Any suggestion?
Do you have installed all lib's in the Arduino IDE for your MKR1010 ?
Write a short programm in the Arduino IDE which call's the analogReadResolution(12) function.
 
Upvote 0

Åke Johansson Bravida

Member
Licensed User
Yes I made this test in Arduino IDE for mkr 1010.

void loop() {

analogReadResolution(12);
Serial.print(", 12-bit : ");
Serial.print(analogRead(A0));

}

Sketch compiled no error.
 
Upvote 0

Åke Johansson Bravida

Member
Licensed User
Ok first i can´t find board type Arduino DUE in my boardlist is there an update to my boardlist?
I tested with MKR1000 and that compiled without any error.
So I changed back to MKR1010 and now it actually compiled without any error ??????? very strange??
Now it´s running.

Problem solved Thank you.
 
Upvote 0
Top