Git Product home page Git Product logo

microsoft / pxt-microbit Goto Github PK

View Code? Open in Web Editor NEW
689.0 64.0 573.0 317.74 MB

A Blocks / JavaScript code editor for the micro:bit built on Microsoft MakeCode

Home Page: https://makecode.microbit.org

License: Other

TypeScript 62.56% C++ 14.55% HTML 0.90% CSS 0.10% JavaScript 16.47% Smalltalk 0.25% C# 2.08% Shell 0.10% Objective-C 1.39% C 0.01% Rich Text Format 0.01% Assembly 0.51% Less 1.07%
typescript blockly microbit makecode pxt code editor education

pxt-microbit's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pxt-microbit's Issues

firefox browser issues - deleting blocks

firefox browser issues - deleting blocks

repro go to this version of firefox
firefox version

  1. open ksf, blocks.

2 add these blocks

blocks not deleting

3 expect to be able to delete these blocks, they are stuck in the drawers

blocks not rendering, again

code was fixed 5 minutes ago, the blocks are not rendering for a second time (after fixing the code - they appeared to be fixed and visibly rendering 5 minutes ago on localhost)

http://localhost:3232/lessons/prank-wifi/activity

basic.showString("Check Wifi", 150)
basic.forever(() => {
    let xAccel2 = Math.abs(input.acceleration(Dimension.X))
    let yAccel2 = Math.abs(input.acceleration(Dimension.Y))
    let zAccel2 = Math.abs(input.acceleration(Dimension.Z))
    let sum2 = xAccel2 + yAccel2 + zAccel2
    if (sum2 < 1200) {
        basic.showLeds(`
. . . . .
. . . . .
. . # . .
. # # . .
# # # . .
`)
    } else if (sum2 >= 1400 && sum2 < 1680) {
        basic.showLeds(`
. . . . .
. . . # .
. . # # .
. # # # .
# # # # .
`)
    }
    else if (sum2 >= 1680) {
        basic.showLeds(`
. . . . .
. . . . .
. . . . .
. . . . .
# . . . .
`)
    }
    if (sum2 >= 1200 && sum2 < 1400) {
        basic.showLeds(`
. . . . #
. . . # #
. . # # #
. # # # #
# # # # #
`)
    }
})

WIN10 APP - Show Code

When you set variable in blocks, then click show Code... the variable is automatically set as null

let item = null;
item = 0;

show code - not supported

show code: not supported in all browsers

1 open browser (MS Edge)

2 enter this code in blocks

basic.showNumber(7)

3 click on show code

image

4 this feature does not work in Edge

light level - documentation

1 open KSF, click blocks

2 enter program using music / light level

image

 let light = 0;
input.onButtonPressed(Button.A, () => {
    music.rest(music.beat(BeatFraction.Sixteenth));
    light = input.lightLevel();
    if (light < 25) {
        music.ringTone(music.noteFrequency(Note.C));
    }
    else {
        music.ringTone(music.noteFrequency(Note.A));
    }
});


3 expect sound to play based on acceleration 'y' in simulator

rotation animation - cannot render blocks/JS

1 go to codemicrobit.com, open JS

2 enter this code

let rotating = true;
input.onButtonPressed(Button.A, () => {
    serial.writeLine("hello")
    rotating = false
})
while (rotating) {
    serial.writeLine("loop")
    basic.showLeds(`
        # . . . .
        . # . . .
        . . # . .
        . . . # .
        . . . . #
        `)
    basic.showLeds(`
        . . # . .
        . . # . .
        . . # . .
        . . # . .
        . . # . .
        `)
    basic.showLeds(`
        . . . . #
        . . . # .
        . . # . .
        . # . . .
        # . . . .
        `)
    basic.showLeds(`
        . . . . .
        . . . . .
        # # # # #
        . . . . .
        . . . . .
        `)
}

3 copy this code into docs...cannot render blocks/JS

image

code not rendering... catch the egg game

the code works in the simulator, but not rendering

open KSF, enter this in JS

let basketX = 2
let eggX = 2
let eggY = 0
basic.forever(() => {
    led.unplot(basketX, 4)
    led.unplot(eggX, eggY)
    eggY = eggY + 1
    led.plot(eggX, eggY)
    basic.pause(300)
    let accX = input.acceleration(Dimension.X)
    basketX = 2 + Math.min(2, Math.max(-2, accX / 200))
    led.plot(basketX, 4)
    if (eggY > 4) {
        eggY = -1
        eggX = Math.random(5)
    }
    basic.pause(300)
})

here is the lesson

http://localhost:3232/lessons/catch-the-egg-game/activity

firefox issue - browser specific

go to either of these browsers: firefox or IE

  1. IE. 11.0.9600.38204
  2. FireFox

firefox version

3 go to codemicrobit.com/latest

  1. drawers/tabs are removed, users only sees first 4 drawers on the block editor

localhost - not able to open in Edge

Repo.

1 Go through steps to open localhost

2 Chrome opens by default

3 copy/paste localhost URL to Edge


http://localhost:3232/index.html#

4 Edge is constantly saying loading... but never finishes loading

image

Excel - Charting

Why is serial only present in an isolated example of on radio received?

Serial is present on data received in this example

basic.forever(() => {
    radio.sendNumber(input.acceleration(Dimension.X))
})
radio.onDataReceived(() => {
    led.plotBarGraph(radio.receiveNumber(), 1023)
})

Serial is not present on data received in this example. Why is this the case?

let jumps = 0
basic.forever(() => {
    let acc = input.acceleration(Dimension.Y)
    if (acc > 2000) {
        jumps = jumps + 1;
        radio.sendNumber(jumps)
        basic.showLeds(`
            . . . . .
            . # . # .
            . . # . .
            # . . . #
            . # # # .
            `)
        basic.clearScreen()
    }
})
input.onButtonPressed(Button.A, () => {
    basic.showNumber(jumps)
})
input.onButtonPressed(Button.AB, () => {
    let jumps = 0
    basic.showNumber(jumps)
})
radio.onDataReceived(() => {
    basic.showNumber(radio.receiveNumber())
    led.stopAnimation()
})

WIN10 APP - Play / Compile (Busted)

  1. new projects, JS
  2. enter this code
let jumps = 0
basic.forever(() => {
    let acc = input.acceleration(Dimension.Y)
    if (acc > 2000) {
        jumps = jumps + 1;
        radio.sendNumber(jumps)
        basic.showLeds(`
            . . . . .
            . # . # .
            . . # . .
            # . . . #
            . # # # .
            `)
        basic.clearScreen()
    }
})
input.onButtonPressed(Button.A, () => {
    basic.showNumber(jumps)
})
input.onButtonPressed(Button.AB, () => {
    let jumps = 0
    basic.showNumber(jumps)
})
radio.onDataReceived(() => {
    basic.showNumber(radio.receiveNumber())
    led.stopAnimation()
})


Run / Compile does not work

create sprites does not work..

1 open KSF, click JS

2 type this code

let hero = game.createSprite(2, 2)
let food = game.createSprite(4, 4)
let ghost = game.createSprite(0, 0)

3 would expect for these sprites to appears on the simulator.

4 the error is shown in blocks too.. see example below

image

4 nothing appears when pressing run

data on plot bar graph...

expectation: You could receive data from a single micro:bit

  1. open KSF, go to JS...

2 enter this code

basic.forever(() => {
    led.plotBarGraph(input.acceleration(Dimension.X), 1023);
});

3 it would be ideal to receive Excel data from a single micro:bit using acceleration, it doesn not appear possible.

game library blocks - issues

open js, enter code

 let ghost = 0;
 let food = 0;
 let hero = 0;
hero = game.createSprite(2, 2);
food = game.createSprite(4, 4);
ghost = game.createSprite(0, 0);


an issue occurs on latest

image

semi colon (syntax) appears optional...

is this intentional ?

1 open JS

  1. type code - error free
let hero = game.createSprite(2, 2);
let food = game.createSprite(4, 4);
let ghost = game.createSprite(0, 0);
ghost.change(LedSpriteProperty.Blink, 100);

  1. type code - error free
let hero = game.createSprite(2, 2)
let food = game.createSprite(4, 4)
let ghost = game.createSprite(0, 0)
ghost.change(LedSpriteProperty.Blink, 100)

convert input light level to JS - automatic set var to 0

convert input light level to JS - automatic set var to 0

1 why do you need to store light level as 0?

2 enter this code in blocks

let light = input.lightLevel();

3 then press show in code

4
this is the code that appears

 let light = 0;
light = input.lightLevel();

2 i would expect when converting from blocks to JS, the code would appear like this

let light = input.lightLevel();

completed - converted lessons

Beginner

  • Beautiful Image, show a beautiful image with show LEDs
  • Lucky 7, show a number on the LED screen with show number
  • Answering Machine, show a text message with show string
  • Game of Chance, show a text message with game over
  • Smiley, smiley and frowney faces that transition on button pressed
  • Magic Logo, show an image on logo up
  • Snowflake Fall, repeat a series of images with forever
  • Screen Wipe, turn off the LEDs with clear screen
  • Flashing Heart, display images with a pause
  • Blink, turn an LED on and off with plot
  • Night Light, dim the LEDs with set brightness
  • Game Counter, displays the player's score with score and add points to score
  • Happy Birthday, create a popular song
    picture
    Intermediate
  • Magic 8, a fortune teller game with the BBC micro:bit
  • Guess the Number, guess a random number with pick number
  • Counter, display a number with a variable
  • Love Meter, create a love meter with on pin pressed
  • Rock Paper Scissors, create the classic game of rock paper scissors with if statement
  • Truth or Dare, a game that forces each player to reveal a secret or do something funny with if statement
  • Spinner, spin the arrow with multiple if statements
  • Die Roll, spin with more if statements
  • Looper, display a series of numbers with a for loop index
  • Strobe Light, develop shapes with a nested for loops
  • Temperature, get the ambient temperature (degree Celsius °C)
  • Digi Yoyo, create a counter with a while loop
  • Rotation Animation, control an animation with a boolean variable
  • Compass, displays the direction the BBC micro:bit is pointing with compass
  • Zoomer, measure the force with acceleration
  • Glowing Pendulum, construct a pendulum that glows using acceleration
  • Classic Beatbox, make a beatbox music player with variables
  • Light Beatbox, make a beatbox music player with light level: need to finish last exercise.
    picture.. broken link ... http://localhost:3232/microbit/lessons/hack-your-headphones/activity

Maker

  • The Watch, design and create The Watch
  • Hack your Headphones, create music on the BBC micro:bit by hacking your headphones -- broken link..
  • Banana Keyboard, create music with fruits
  • Telegraph, play the telegraph game between two BBC micro:bits
  • Ornament Chain, play the ornament chain game between two BBC micro:bits
    Advanced
  • Hero, reconstruct the classic arcade game pac man with the BBC micro:bit

music blocks - blocks to JS

music blocks - blocks to JS

1 in reference to the light beatbox lesson

http://localhost:3232/lessons/light-beatbox/activity

2 enter this code with blocks

let light = 0;
input.onButtonPressed(Button.A, () => {
    music.rest(music.beat(BeatFraction.Sixteenth));
    light = input.lightLevel();
    if (light < 25) {
        music.ringTone(music.noteFrequency(Note.C));
    }
    else {
        music.ringTone(music.noteFrequency(Note.A));
    }
});

3 press convert.

4 i would expect the code to be equal to the following when using ringTone using JS without Blocks

input.onButtonPressed(Button.A, () => {
    music.rest(BeatFraction.Sixteenth)
    let light = input.lightLevel()
    if (light < 25) {
        music.ringTone(Note.C)
    }
    else {
        music.ringTone(Note.C);
    }
})

4 however, the conversion is not 1:1. Am i missing something when using music with JS vs using music with blocks ?

Turbine Presentation

the code is working in microbit.co.uk, not in codemicrobit.com

repro:

import code to microbit.co.uk

https://www.microbit.co.uk/jvkblk

import code to codemicrobit.com

https://codemicrobit.com/tgukzgtdzg

 let higherLimit = null;
 let voltage = null;
 let high_voltage = null;
input.onButtonPressed(Button.A, () => {
    basic.showNumber(high_voltage);
    basic.pause(2000);
});
high_voltage = 0;
higherLimit = 1024;
basic.forever(() => {
    voltage = pins.analogReadPin(AnalogPin.P0);
    if (voltage > high_voltage) {
        high_voltage = voltage;
    }
    else {
        led.plotBarGraph(voltage, higherLimit);
    }
});

here is a screenshot of the program working

image

when this program is loaded in codemicrobit.com, the same program is NOT working


 let voltage = null;
 let higherLimit = null;
 let high_voltage = null;
input.onButtonPressed(Button.A, () => {
    basic.showNumber(high_voltage);
    basic.pause(2000);
});
high_voltage = 0;
higherLimit = 1024;
basic.forever(() => {
    voltage = pins.analogReadPin(AnalogPin.P0);
    if (voltage > high_voltage) {
        high_voltage = voltage;
    }
    else {
        led.plotBarGraph(voltage, higherLimit);
    }
});


screenshot

image

the error message is ...

Voltage implicitly has an error type...

image

So I changed this to...

 let voltage = null;
 let higherLimit = null;
 let high_voltage = null;
input.onButtonPressed(Button.A, () => {
    basic.showNumber(high_voltage);
    basic.pause(2000);
});
high_voltage = 0;
higherLimit = 1024;
voltage = 0;
basic.forever(() => {
    voltage = pins.analogReadPin(AnalogPin.P0);
    if (voltage > high_voltage) {
        high_voltage = voltage;
    }
    else {
        led.plotBarGraph(voltage, higherLimit);
    }
});

possible issue:

the variables are not updating -> variables consistently showing Null

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.