Skip to content

music.pitch seems to cause fluctuations in read_analog results #66

Closed
@AndyLindsay

Description

@AndyLindsay

A call to music.pitch seems to affect the results of the next read_analog call.

Edit: The symptoms are evident with or without a sleep call between music.pitch and pin0.read_analog.

Test Script

# music_pitch_v_read_analog
# connect pin0 to 3.3 V

from microbit import *
import music

n = 0

while True:
    n += 1
    if (n%5) == 0:
        print("beep")
        music.pitch(3000, 100)
    #sleep(100)
    v0 = pin0.read_analog()
    print("v0 =", v0)
    if v0 < 1010:
        print("pin0 measurement error")
        sleep(2000)
    sleep(100)

Terminal Results

v0 = 1020
v0 = 1021
v0 = 1021
v0 = 1020
beep
v0 = 958
pin0 measurement error
v0 = 1021
v0 = 1021
v0 = 1020
v0 = 1021
beep
v0 = 957
pin0 measurement error
v0 = 1021
v0 = 1021
v0 = 1021
v0 = 1021
beep
v0 = 957
pin0 measurement error
v0 = 1021
v0 = 1021
v0 = 1021
v0 = 1021
beep
v0 = 957

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions