Skip to content

Instantly share code, notes, and snippets.

View microbit-carlos's full-sized avatar

Carlos Pereira Atencio microbit-carlos

View GitHub Profile
@microbit-carlos
microbit-carlos / build-pxt-codal.sh
Last active March 27, 2024 16:26
Build MakeCode with local CODAL build
# Make sure node is at v16
# asdf local nodejs 16.19.1
git clone https://github.com/microsoft/pxt-microbit.git
cd pxt-microbit
npm install pxt --no-save
npm install
# To use a different CODAL version the branch/tag can be configured changing pxtarget.json
@microbit-carlos
microbit-carlos / button_outputs.py
Created August 8, 2022 17:17
micro:bit V2 MicroPython configure buttons as outputs
from microbit import *
from micropython import const
from machine import mem32
REG_GPIO_P0 = const(0x50000000) # Base address for the GPIO 0 peripheal
REG_GPIO_OUTSET = const(REG_GPIO_P0 + 0x508) # When a 32bit value is written to this address, each bit set to 1 sets the output pin high
REG_GPIO_OUTCLR = const(REG_GPIO_P0 + 0x50C) # When a 32bit value is written to this address, each bit set to 1 sets the output pin low
REG_GPIO_DIRSET = const(REG_GPIO_P0 + 0x518) # When a 32bit value is written to this address, each bit set to 1 sets the pin to output
REG_GPIO_DIRCLR = const(REG_GPIO_P0 + 0x51C) # When a 32bit value is written to this address, each bit set to 1 sets the pin to input
@microbit-carlos
microbit-carlos / adc_config_test.py
Last active July 19, 2017 14:17
micro:bit MicroPython ADC config test
from microbit import pin0, pin1
NRF_ADC_BASE = 0x40007000
NRF_ADC_CONFIG = NRF_ADC_BASE + 0x504
@micropython.asm_thumb
def reg_read(r0):
ldr(r0, [r0, 0])
@micropython.asm_thumb
@microbit-carlos
microbit-carlos / adc_ref_volt.py
Last active June 28, 2022 18:43
micro:bit MicroPython change ADC reference voltage
from microbit import pin0
NRF_ADC_BASE = 0x40007000
NRF_ADC_CONFIG = NRF_ADC_BASE + 0x504
@micropython.asm_thumb
def reg_read(r0):
ldr(r0, [r0, 0])
@micropython.asm_thumb