KRITSADA

EEprom test

Sep 12th, 2018
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let Result = 0
  2. let i = 0
  3. input.onButtonPressed(Button.A, () => {
  4.     basic.showNumber(1)
  5.     for (let i = 0; i <= 9; i++) {
  6.         AT24C256.write_byte(i, i)
  7.         basic.pause(1)
  8.     }
  9.     Result = 0
  10.     for (let i = 0; i <= 9; i++) {
  11.         if (AT24C256.read_byte(i) == i) {
  12.             Result += 1
  13.         }
  14.     }
  15.     if (Result == 10) {
  16.         basic.showIcon(IconNames.Yes)
  17.     } else {
  18.         basic.showIcon(IconNames.No)
  19.     }
  20.     basic.pause(600)
  21.     basic.showNumber(2)
  22.     for (let i = 0; i <= 9; i++) {
  23.         AT24C256.write_byte(i, 255)
  24.         basic.pause(1)
  25.     }
  26.     Result = 0
  27.     for (let i = 0; i <= 9; i++) {
  28.         if (AT24C256.read_byte(i) == i) {
  29.             Result += 1
  30.         }
  31.     }
  32.     if (Result == 10) {
  33.         basic.showIcon(IconNames.Yes)
  34.     } else {
  35.         basic.showIcon(IconNames.No)
  36.     }
  37. })
Advertisement
Add Comment
Please, Sign In to add comment