Guest User

Untitled

a guest
May 20th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. String userInput = bufferedReader.readLine(); // reads a user-inputted string of text byte[] byteArray = userInput.getBytes(); // text is converted into byte array and stored in byteArra int parityBit = 0; // creates the parity value for ( int b: byteArray){     parityBit += b; // every byte is added to the parity bit } byteArray.add(parityBit%2); // the parityBit modulo two is added to the byte array. if paritybit is even, 0 is added. if parityBit is odd, 1 is added Serial serial = new Serial(new PApplet()); // opens up a serial port serial.write(byteArray); // bytearray is sent over serial
Add Comment
Please, Sign In to add comment