## Controlling mouse movement with wind
This week our individual assignment was to design, build and connect wireless nodes with network or bus address and a local interface. Our group assignment was to send a message between two projects.
### Group project
I worked with Alan to communicate wirelessly over wifi between my wind sensor (from [input week](/Users/gauriagarwal/cbasite/people/Gauri/week_8/input_devices.html)) with [Alan's mouse program](https://fab.cba.mit.edu/classes/863.23/CBA/people/Alan/projects/w11_net/README.html#wireless-mouse) using two pico W.
![comm](../media/week_10/communication_between_students.jpeg)
Here is a simple code to add ip server capability to communicate over hotspot.
```
from machine import Pin, ADC
import network
import random
import socket
import time
from machine import ADC, Pin, I2C
ssid = 'your_ssid'
password = 'your_password'
# Just making our internet connection
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(ssid, password)
# Wait for connect or fail
max_wait = 10
while max_wait > 0:
if wlan.status() < 0 or wlan.status() >= 3:
break
max_wait -= 1
print('waiting for connection...')
time.sleep(1)
# Handle connection error
if wlan.status() != 3:
raise RuntimeError('network connection failed')
else:
print('connected')
status = wlan.ifconfig()
# Open socket
addr = socket.getaddrinfo('0.0.0.0', 80)[0][-1]
s = socket.socket()
s.bind(addr)
s.listen(1)
print('listening on', addr)
wind_sensor_pin = ADC(Pin(28))
# Listen for connections
while True:
try:
cl, addr = s.accept()
request = cl.recv(1024)
print(request)
digital_value = wind_sensor_pin.read_u16()
print("ADC value =", digital_value)
voltage_value = 3.3 * (digital_value/65536)
print("Voltage: {}V".format(voltage_value))
degrees = (voltage_value/3.1) * 360
print("Wind degree: {} degrees".format(int(degrees)))
strtosend = str(int(degrees))
print(strtosend)
#encoding the wind sensor data to decode on client side
if (len(strtosend) < 3):
zeroes = 3 - len(strtosend)
strtosend = (zeroes * "0") + strtosend
print(strtosend)
cl.send(strtosend)
cl.close()
print("hello pico 1 closed it")
except OSError as e:
cl.close()
print('connection closed')
```
This video shows the messages sent between both our projects:
We were able to send messages between our projects and control the Alan's mouse by changing the wind angle on the wind sensor. Alan added a wifi client to his existing mouse.h code from [previous weeks](https://fab.cba.mit.edu/classes/863.23/CBA/people/Alan/projects/w09_in/README.html#an-hmi-to-surpass-mouse-and-pad).
As you can see in the video, the mouse movement is neglible. This was probably because the math to output the mouse movement
was an order of magnitude off and we couldn't make the mouse behave and decode wind direction information reliably.
But the mosue did react to the wind sensor!
### Individual Assignment
Please look at my documentation from next week - [Application Programming](../week_11/interface_program.html) where I did satisfied the "local interface" part of the assignment, opening a webserver on a pico w and connecting my client to the webserver to recieve local wind information.