How can I activate an internal pullup resistor on an analog pin (using ArduBlock blocks)?

159 views
Skip to first unread message

Matthew Rody

unread,
Dec 7, 2016, 11:09:22 AM12/7/16
to Ardublock
I am trying to create a very simple program using ArduBlock, which utilizes a photoresistor as an input. I'm using the Arduino Uno board, and I've connected the photoresistor from A1 to GND. I know from reading that the Uno has internal resistors on the analog input pins that can be activated with the line "digitalWrite (A1, HIGH);". However, I can't figure out if it's even possible to generate this line of code using ArduBlock. (I am using ArduBlock version 21040826.)

If I attempt to set pin A1 to HIGH during the program Setup, the resulting code is "digitalWrite (1, HIGH);" (see images below). But what I really want is "digitalWrite (A1, HIGH);".


If I try to use the "set analog pin" block, then I can no longer set the value to "HIGH"; it must be a numeric value. (See below.)



Is there something I'm missing here? Or is this just one of the limitations of using Ardublock? I'm fine manually entering the extra line of code myself, but I'm trying to teach Arduino/Ardublocks to students who are learning to code for the first time, and I'd like for it to be as seamless as possible. So if there's a simple way to do this using ArduBlocks, I'd love any help.


Thanks!


Matthew

Marcus Shaw

unread,
Dec 7, 2016, 11:14:12 AM12/7/16
to Ardublock
Hello :-)

I haven't tried in Ardublock, but you can also address the analog pins with their defined pin numbers instead of A(n).

On the Uno, analog pin A0=14, A1=15 and so on (also see hardware/arduino/avr/variants/standard/pins_arduino.h), for the Mega it's A0=54.


Matthew Rody

unread,
Dec 7, 2016, 12:32:48 PM12/7/16
to Ardublock
Thanks for the helpful info Marcus!

I tried referring to the Analog pin using it's digital number, and I got the following output:

 


This program did not function as desired. The onboard LED just stayed on the whole time. HOWEVER, when I commented out the first line (setting pin A1/15 as an output), the program worked perfectly.

So, it appears that Marcus's solution works to a degree. However, using the "set digital pin" block in ArduBlock automatically creates the "pinMode (15, OUTPUT);" line, which renders the use of that pin as an input useless.


Any other ideas?


Thanks,

Matthew

Alexander Wilkes

unread,
Dec 19, 2016, 7:52:27 AM12/19/16
to ardu...@googlegroups.com
Hi Ardublock fellows :-)

Does anybody know, how to create PWM-reading inputs with Ardublock (Scoop Version)?
It’s necessary to read PWM signals from different RC-receiver channels.

Thanks in advance,
Alex



--
You received this message because you are subscribed to the Google Groups "Ardublock" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ardublock+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

_____________________________
Alexander Wilkes

Königstrasse 25
61191 Rosbach

Tel.: 06007 / 9394238
Mobil: 0172 / 4943128


Reply all
Reply to author
Forward
0 new messages