Upgrade to Pro — share decks privately, control downloads, hide ads and more …

2 proyectos y 1 destino

2 proyectos y 1 destino

Slides de la charla de 2 proyectos y 1 destino impartida en Codemotion Madrid 2019

Avatar for Azahara Fernández Guizán

Azahara Fernández Guizán

September 24, 2019
Tweet

More Decks by Azahara Fernández Guizán

Other Decks in Programming

Transcript

  1. Copyright © Sngular. All rights reserved. Dos proyectos y un

    destino: Javascript of things! Azahara Fernández Guizán/ Juan Manuel Rodríguez Pérez 24-25 September, 2019
  2. Copyright © Sngular. All rights reserved. Juan Manuel Rodríguez Pérez

    @juan_manuel_rp jmrp81 Azahara Fernández Guizán @Azahara_fergui azaharafernandezguizan
  3. Copyright © Sngular. All rights reserved. ¿Por qué Javascript of

    things? 3 Curva de aprendizaje Node modules Angular of Things
  4. Copyright © Sngular. All rights reserved. 4 Jhonny Five: http://johnny-five.io/

    Node y GPIO https://www.w3schools.com/nodejs/nodejs_raspberrypi_gpio_intro.asp Raspberrry PI https://www.raspberrypi.org/ Luis Llamas https://www.luisllamas.es/tutoriales-de-arduino/ Programar es una mierda https://www.programaresunamierda.com/p/comunidad-en-slack.html Recursos
  5. Copyright © Sngular. All rights reserved. ENTORNO DE PROGRAMACIÓN 7

    $ sudo apt full-upgrade –y $ sudo apt-get update $ sudo apt-get remove nodered –y $ sudo apt-get remove nodejs nodejs-legacy –y $ curl -sL http://deb.nodesource.com/setup_11.x | sudo bash - $ sudo apt-get install -y nodejs 1. Actualizar 2. Desinstalar Node 3. Instalar Node
  6. Copyright © Sngular. All rights reserved. INTERACCIÓN CON LOS COMPONENTES

    11 const Gpio = require('onoff').Gpio; // Led var turnOnLed = new Gpio(18, 'out'); var falseAnswerLed = new Gpio(20, 'out'); var trueAnswerLed = new Gpio(21, 'out'); // Buttons var questionButton = new Gpio(26, 'in', 'both'); var answerAButton = new Gpio(19, 'in', 'both'); var answerBButton = new Gpio(13, 'in', 'both'); var answerCButton = new Gpio(06, 'in', 'both');
  7. Copyright © Sngular. All rights reserved. INTERACCIÓN CON LOS COMPONENTES

    12 // actions turnOnLed.writeSync(1); questionButton.watch(function (error, value) { if (error) { console.log('error' + error); return; } if (value === 1) { // pulsado currentQuestion = gameService.GetQuestion(); picoSpeakerService.speakText(currentQuestion.text); });
  8. Copyright © Sngular. All rights reserved. TEXT TO SPEECH 13

    PICO SPEAKER const picoSpeaker = require('pico-speaker'); var picoConfig = { LANGUAGE: 'es-ES' }; picoSpeaker.init(picoConfig); module.exports = { speakText: function (textToSpeak) { picoSpeaker.speak(textToSpeak).then( function() { }.bind(this)); } }
  9. Copyright © Sngular. All rights reserved. ANGULAR OF THINGS 14

    Node REST API con autenticación con JWT, Tests con Mocha y Supertest. Base de datos MariaDB. Aplicación Angular 8 con autenticación con JWT, Tests con Karma y gráficos con Chart.js.
  10. Copyright © Sngular. All rights reserved. JOHNNY FIVE 20 ¿Qué

    es? JavaScript Robotics & IoT Platform Mantenida por la comunidad Arduino, Raspberry Pi Facilita el uso y conexión de componentes con las boards
  11. Copyright © Sngular. All rights reserved. ENTORNO DE DESARROLLO 21

    ¿Qué he usado? Raspberry Pi 3 B con Raspbian y Node Visual Studio Code NPM (Johnny Five, Raspi-io)
  12. Copyright © Sngular. All rights reserved. CREANDO EL PROYECTO 22

    • Creamos carpeta para el proyecto • Creamos el package.json → npm init • Instalar Johnny Five • Instalar Raspi-io • Cramos archivo .js • Ejecutar código → node [archivo].js
  13. Copyright © Sngular. All rights reserved. LÓGICA JUEGO 24 Importación

    ficheros y librerías Objeto board y método ‘on’