 Okay, hi. So I'm Pasindu. I actually haven't been coding in PHP for about two years now. I used to .NET, so if you enter the PHP manual, and I mostly did many of PHP 7 documentations. So yeah, if you want to later talk about PHP, how to get involved in PHP internals, write documentation, or bug fixes, all those kind of things, I can help you out. Okay, so PHP bots. Okay, so how many of y'all have used a bot? Okay, so this is kind of the, typically the first thing that comes to your mind when you say bots these days, because it's like chatbots are everywhere, and there's so many talks on bots and everything. So I thought because there's a demand for chatbots, I'll not be doing that today. I'm doing something else. So the bot I'm going to do is there. So it's an hardware. Can we do PHP on hardware? Is it easy, hard? What do you think? Any ideas, any thoughts? And also just to put a disclaimer, this is purely for fun. I'm not endorsing it. I'm not encouraging people to do it. I'm just showing some things. So typically the problem with PHP for anything is PHP always needs a server or things like that. It's not compiled, so you kind of, it's not compiled, so you cannot kind of run it like you would do any other binary. So hardware typically has been for like C, C++ developers. Recently there are things that have come up which enables normal human beings like us who uses PHP or other languages to maybe fiddle with hardware a bit. Okay, so I'll be running through some demos. So typically what has been invented recently of some time back actually is something called Firmata. So Firmata is a firmware that you can put on an Arduino Nano or an Arduino Uno or any number of Arduino's or it can be put on some other devices, compatible devices as well. Of it as a REST API for hardware. So you send in, you want your hardware to do something. You can send a request. It will do it for you. If you want to get some information out of it, you can send another request and it will send you the results out of it. So Firmata is, okay. So Firmata, because it's a firmware, it is language independent. So I got into this because I used to do PHP notebooks a lot. And if you've been for JS, Conf Asia, I did a workshop there. So that's how I got into this. So Firmata has a lot of clients in any language, a lot of languages, and PHP is one of them. Okay, so to this actual slide now. So I have a, let's see. So to get started is, the way you get started on this is you have to, if you have access to an Arduino Nano or Arduino Uno, you can just use the Arduino IDE, which is this Arduino IDE. Go to, go to examples, and, ah, ah, okay. So this is Firmata. Okay, you can flash Firmata, standard Firmata on your Arduino Nano, and then you can actually use Node.js or JavaScript or anything after that. So let's try to see whether we can do this using, okay, so for this, I'm using, for PHP, the client is called something, dash from Firmata, I don't know how to say it, Firmata. I'm just going to call it the Firmata client. Okay, that was wrong. Okay, so typically the first thing that you run on, if you're new into hardware, is something called the Blinky. So Blinky is something where there's an LED and it's just Blinky. That's all it is. Okay, so when you got this Firmata client, one of the first things you have to do is, you have to, there's a bootstrap that kind of gets your, gets your objects. So there's a typical, there's different ways you can communicate with the, communicate with the Nano. One way is you communicate with it directly in serial, or you can have a TCP server in front of it where it's your serial to your hardware, or the Nano. Okay, next you have to set your ports. So this is my serial, I think. Okay, so after that you come to the Blinky. So in Blinky it's pretty, if you're into PHP, you'll probably get the gist of it. So there's a, this is an anonymous class that you're using, and there is both that you can, that kind of holds everything that you want. So let's try running it and then I can say what's actually happening. The light is blinking. Let me, yay, we saw you, so we use PHP. So that's the easy part. Okay, so basically, I'm not going to talk more, lot about the board. So Arduino and Nano has typically three pins, three types of pins, analog, digital, and there's something called the PWM pin. It's something between a digital and a analog kind of. So what we're doing here is we are using pin number 10. For LED, we are saying it's an output pin. Basically we are sending something that it's supposed to output. And then we have our loop and we have a set interval and then we just call it every second that just goes on and off. Yeah, that's pretty, okay. So let's try to see whether we can do this. Okay, cute, okay. What we're supposed to have is called is the laser, which is, okay, so this is a laser. What's going on? No. Okay. Does it make the lightsaber sound? Yeah, I should have, I should have. Okay, so those are the output things that you can do with the board. So that's interesting, that's cute. But let's try to see whether we can get something out of a sensor. So the sensor that I have is called the hard bit sensor. So let's try whether this works. So just to go back on the laser, it's pretty much the same thing. Everything about digital stuff is same, one or zero on and off. It's pretty simple there. Okay, let's see the hard bit pulse, I believe. So if you can see this, you'll see something. This is extremely unreliable. So that's the problem that you, when you try to do this stuff, that's the biggest problem that you can have is your hardware is going to be the issue. Okay. Yeah, so if you are doing hardware, it's easy to blame people. You can say it's just hardware, not my code. Pretty easy. Okay, so the hardware is analog. So in this, I get my pin to, yeah, 14, it's analog, and I just read it. It's kind of an event loop, event on kind of thing, where it will, every time it calls code will run, and I can see it. Okay, so that's that, and see what else we have. Okay. So all these things are, if you know MIDI, MIDI controllers, audio MIDI, those things. So this is something that this formata messaging is kind of built on top of it, with some extra additions. So yeah, okay. So something else. So this is the car that I was talking about. So we did it in PHP, and you can actually just do it in, sorry, we previously did it in Node.js, and then you can actually do the same thing in PHP also. Yeah, if you can see, not pretty printed, but you can see, and space to stop it. Okay, let's see how that thing works. Okay, so this thing, so the hardest thing I found out when I was trying to do this, was how to get a key press every single time, without it being buffered. That was the hardest thing that I found, it was not the hardware, it was not anything else, it was just PHP. Being, I guess used to Node.js and stuff on events and every thing there. Okay, so I have two motors servers, which is on pin nine and 10. So those are PWM pins. I have a map of up-down keys. I read it, and then I do the things that I want to. So this analog, I'm setting, so when I press up, it needs to go forward, but so if you can see, this is inverse because the motors are reversed, because they are on both sides. Therefore, if both the direction of both are not the front at the same time, because they are on the opposite sides, because one motor is on this side rotating clockwise, the other one would be turning anti-clockwise if you do it, because it's on the other side. So that's why it might be just confusing that they are set into different values. So this scales between one to zero to one, and actually it actually scales from this software would scale it, for each and all stuff, everything is just zero to one, and then consider the value being speed and direction. And this is down, as you can see, I'm doing the same thing in reverse, and so when I'm doing left-right, I just do differential, and then so the one, basically differential. And stop is kind of stop, that's the big deal there. So, yeah, so you can do these kind of things with, so if you have been coding in PHP for a long time, it's, get into this, then I do, because I had to remember a lot of PHP basics to get this working. So, yeah, you can try it at home and see whether you find something interesting to do. Yeah, so this client that I'm using is pretty good. It has functionalities, but if you want to move kind of sophisticated, they do have seven-segment displays that if you want to show, if you want to have like LED matrix, and things like that, it becomes a bit harder to do it in this client, but you can, once you get into this, you can probably get it working. So, yeah, that's pretty much it for me. Thanks. Any questions? Yeah. So, Firmata is a client where you are compiling the page? No, no, okay, so that's, so Firmata is, it works on the serial port. So you can, so you, so basically I flash Firmata onto this board and it talks through the serial port to me. So I can run send commands to say, pin 11 on pin 12 of get me the output from pin 20 or something like that. So it's basically under, so the, if you think about it, the problem becomes the, there should be always a tethered USB. So the people that work around there found out it is they put a, they have a Wi-Fi shield or Raspberry Pi on top of it and then attach its serial to it and then communicate to the Raspberry Pi via REST or anything. Yeah, that's it. So here it is, how it is communicating through any Raspberry Pi? No, no, it's just, I'm just sending bytes through the serial port to say, do this, do that. It's just, yeah, it just think of it as the Firmata as a REST API. So I'm saying pin 11 on, pin 11 off and it just listens to on the serial port. Basically sending serial port messages and when the port message comes in, it calls back our anonymous functions and then kind of runs them. Yeah, yeah, that's all. So what are the use cases you can do it actually? Oh, you can do anything you want to. Yeah, yeah, yes, you can do it. But you know, should you? Yeah, yeah, exactly, nobody kind of asks, right? Should you do it in PHP? It would be interesting if you can write an application and kind of talk to this stuff. Yeah, it's good because if you know PHP, it's just walking the park for you. Like you don't have to run C++ or any other thing. So that's what your added advantage that you have, not kind of anything else. If you have any sensor, if you connect with this thing, that can send the data to other applications. Yeah, perfect. Yeah, yeah, you can do object type printing and everything. Yeah, yeah, you can look at the comments I have. But you can clearly see this is task code. Like PSR2 violations, like spaces, intense, like horrible. Yeah, okay, that's all. Thanks, guys. Thank you.