0

Trying to set Digital output pin True and False
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Trying to set Digital output pin True and False

by Jerryy on Mon Apr 12, 2021 11:17 pm

I was trying to better understand how CircuitPython works on a Trinket M0. From the Trinket M0 documentation it appears that A0-A5 are general purpose I/O pins.
I ran the following program and then measure the voltage on Pin A0 with a DC meter. I expected the voltage to go high (3.3 V) for 5 seconds then go low (0 V) for 5
seconds and then repeat these values till the program is stopped. What I saw at A0 however is more like a constant .19 V value. Anyone have any idea what I am
doing wrong. All suggestions gratefully accepted.

Thanks

Jerry


Code: Select all | TOGGLE FULL SIZE
import time
import board
from digitalio import DigitalInOut, Direction, Pull

# Output Pin setup.
output_pin  = DigitalInOut(board.A0)
output_pin.direction = Direction.OUTPUT
 
while True:
  output_pin.value = True
  print("5 V")
  time.sleep(5)
  output_pin.value =  False
  print("0 V")
  time.sleep(5)

Jerryy
 
Posts: 24
Joined: Thu Feb 22, 2018 9:06 pm

Re: Trying to set Digital output pin True and False

by dastels on Tue Apr 13, 2021 11:01 am

2 Things:
- use D0 rather than A0
- it will be ~3.3v, not 5v since the TrinketM0 is a 3.3v board.

Dave

dastels
 
Posts: 6432
Joined: Tue Oct 20, 2015 3:22 pm

Re: Trying to set Digital output pin True and False

by Jerryy on Tue Apr 13, 2021 12:24 pm

Thanks Dave:
Tried your suggestion and it worked perfectly :-)

Jerry

Jerryy
 
Posts: 24
Joined: Thu Feb 22, 2018 9:06 pm

Please be positive and constructive with your questions and comments.