diff --git a/Instrukcje.md b/Instrukcje.md
index 54d5158f1de791ad00f1cac949a3f7385219af9f..cfbc190175f6123d0ac3b19f4da7f2eab5bb3bbf 100644
--- a/Instrukcje.md
+++ b/Instrukcje.md
@@ -184,28 +184,29 @@ Tranzystory są elementami elektronicznymi które przewodzą prąd warunkowo. Wa
  
 Źródła:
 img: https://www.vhv.rs/viewpic/iJxRhbb_free-vector-electronic-phototransistor-pnp-circuit-phototransistor-symbol/ 
- 
- 
 
+
+## Konwerter analogowo-cyfrowy 
+ W przypadku diody w lab1 API nrf52 zajęło się wszystkimi niskopoziomowymi problemami za nas, by zapalić diodę. Jeśli chcemy wysterować lub odczytać inny element musimy napisać sterownik samemu. Do tego możemy użyć znanego już GPIO lub ADC  (Analog-Digital Converter), korzystając z niskopoziomowego API tych modułów. 
  
- 
+Konwerter ADC zamienia wartość analogową (napięcie) na wartość cyfrową (liczbę w pamięci).
+
+== TODO ==
 
-## Zaawansowana obsługa GPIO 
 
- 
-W przypadku diody w lab1 API nrf52 zajęło się wszystkimi niskopoziomowymi problemami za nas, by zapalić diodę. Jeśli chcemy wysterować lub odczytać inny element musimy napisać sterownik samemu. Do tego możemy użyć znanego już GPIO lub ADC  (Analog-Digital Converter), korzystając z niskopoziomowego API tych modułów. 
 
-Podłączmy nasz fototranzystor podobnie jak diodę z lab1, lecz ustawmy GPIO w tryb wejścia. Wtedy zmiana stanu fototranzystora pod wpływem światła wznowi lub zatrzyma przepływ prądu. Jest do jednoznaczne z podłączeniem naszego pinu GPIO z napięciem 3.3V (gdy tranzystor przewodzi - tworzy połączenie między swoimi pinami), lub odłączeniem go od tego zasilania (gdy tranzystor nie przewodzi). Innymi słowy fototranzystor staje się swego rodzaju przełącznikiem. Za pomocą API GPIO jesteśmy w stanie odczytać wartość na pinie GPIO w naszej aplikacji jako jedynkę lub zero. 
- 
-Problem jaki się tu pojawia to jednowątkowość naszego mikrokontrolera. Odczyt wartości GPIO jest instrukcją, linią w kodzie, więc jeśli chcielibyśmy  wykonać jakąś operację gdy zmieni się wartość natężenia światła musielibyśmy czytać tą wartość w pętli i czekać aż się zmieni (polling). Pilnowanie tej wartości i robienie innych operacji nie wchodzi wtedy w grę. Na pomoc przychodzą nam przerwania - możemy ustawić je tak by zmiana wartości na pinie GPIO generowała przerwanie. Dzięki temu nasz program będzie mógł się zająć innymi operacjami podczas tego oczekiwania. 
- 
 ## Zadania 
- 
- ​	GPIO (General Purpose Input/Output) czyli wejścia/wyjścia ogólnego przeznaczenia, są to piny służace do komunikacji pomiędzy elementami systemu (np. między mikrokontrolerem a urządzeniami peryferyjnymi). Takie wyprowadzenia mogą pełnić rolę zarówno wejść jak i wyjść, i jest to zazwyczaj właściwość konfigurowalna. Ważną własnością urządzeń korzystających z interfejsu GPIO jest możliwość zgłaszania przerwań.
 
-​	Do naszego modułu nRF52840, a dokładniej do pinu P0.20 podłączony został fototranzystor. Fototranzystor to element optoelektroniczny, który pod wpływem światła zmienia napięcie na swoim wyjściu. Można zastosować go jako prosty detektor światła. 
 
-​	Korzystając z wiedzy zdobytej w poprzednich ćwiczeniach oraz dokumentacji https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/hardware_driver_gpiote.html stwórz prosty czujnik oświetlenia. Program powinien działać w taki sposób, aby po jego uruchomieniu zapaliła się dioda, natomiast po zapaleniu światła (korzystając z interfejsu webowego) dioda zgasła. Zainicjalizuj pin, do którego podłączony jest fototranzystor jako wejście, skonfiguruj w odpowiedni sposób przerwanie oraz napisz funkcję obsługującą to przerwanie. Dla parametru konfiguracyjnego `pull` ustaw wartość `NRF_GPIO_PIN_PULLUP` (tak jak w sekcji *Initialization* dokumentacji).
+	Głównym celem ćwiczenia jest napisanie prostego czujnika oświetlenia który zapala diodę 1 i 0 gdy światło jest zgaszone, i gasi diody gdy światło jest zapalone.
+	Do naszego modułu nRF52840, a dokładniej do pinu P0.02 podłączony został fototranzystor. Fototranzystor to element optoelektroniczny, który pod wpływem światła zmienia napięcie na swoim wyjściu. Można zastosować go jako prosty detektor światła. Pin P0.02 jest pinem z analogowym wejściem(AIN). We wprowadzeniu do Zad1 jest fragment pinoutu mikrokontrolera - sprawdź jaki numer wejścia analogowego ma ten pin.
+	Według dokumentacji uzupełnijcie inicjalizację SAADC tak by odbierać skwantyzowane próbki napięcia na pinie P0.02 i wysyłać tą wartość na USB. Niech timer odmierza kolejne próbki. Możecie przekształcić tą wartość na faktyczne napięcie w mV mnożąc ją : value*(3.3 + 0.3) * 1000)/1024)  [wyjaśnienie wzoru w dokumentacji]. Sprawdźcie jak zmienia się ta wartość gdy światło jest zapalone i zgaszone i na tej podstawie wybierzcie jakąś wartość graniczną. 
+	
+Dokumentacja:
+https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v16.0.0%2Fgroup__nrf__drv__saadc.html&anchor=ga4f67c6dad745133956b9ffc9df68d145
+https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v16.0.0%2Fgroup__nrfx__saadc.html&anchor=gab71a209892aedc84800887de200c5857
+
+	
 
 # Lab 4   
 
@@ -353,4 +354,4 @@ Przykładem serwisu jest LED Button Service. Jest to prosty serwis pozwalający
  
 
  
- 
\ No newline at end of file
+ 
diff --git a/cw3_template/.vscode/settings.json b/cw3_template/.vscode/settings.json
index 8c07ffd4774c091e23683c2691af71cfcc30da30..76a164f3f7e5f5d87461cdc5ec3f61b554a59a74 100644
--- a/cw3_template/.vscode/settings.json
+++ b/cw3_template/.vscode/settings.json
@@ -7,5 +7,9 @@
     "editor.rulers": [90],
     "nrf52SDKPath": "${workspaceFolder}/../../../",
     "userName": "root",
-    "group": "08"
+    "group": "07",
+    "files.associations": {
+      "kimia_usb_log.h": "c",
+      "nrfx_saadc.h": "c"
+    }
   }
\ No newline at end of file
diff --git a/cw3_template/kimia_usb_log.c b/cw3_template/kimia_usb_log.c
new file mode 100644
index 0000000000000000000000000000000000000000..d96f5822360f62fce08bff2884bb029bf3f37830
--- /dev/null
+++ b/cw3_template/kimia_usb_log.c
@@ -0,0 +1,200 @@
+#include "kimia_usb_log.h"
+
+
+
+#include "nrf_log.h"
+#include "nrf_log_ctrl.h"
+#include "nrf_log_default_backends.h"
+
+#include "app_usbd_core.h"
+#include "app_usbd.h"
+#include "app_usbd_string_desc.h"
+#include "app_usbd_cdc_acm.h"
+#include "app_usbd_serial_num.h"
+
+
+
+
+static void cdc_acm_user_ev_handler(app_usbd_class_inst_t const * p_inst,
+                                    app_usbd_cdc_acm_user_event_t event);
+
+
+
+
+
+/**
+ * @brief CDC_ACM class instance
+ * */
+APP_USBD_CDC_ACM_GLOBAL_DEF(m_app_cdc_acm,
+                            cdc_acm_user_ev_handler,
+                            CDC_ACM_COMM_INTERFACE,
+                            CDC_ACM_DATA_INTERFACE,
+                            CDC_ACM_COMM_EPIN,
+                            CDC_ACM_DATA_EPIN,
+                            CDC_ACM_DATA_EPOUT,
+                            APP_USBD_CDC_COMM_PROTOCOL_AT_V250
+);
+
+
+
+static char m_rx_buffer[READ_SIZE];
+static char m_tx_buffer[WRITE_SIZE];//NRF_DRV_USBD_EPSIZE
+
+/**
+ * @brief User event handler @ref app_usbd_cdc_acm_user_ev_handler_t (headphones)
+ * */
+static void cdc_acm_user_ev_handler(app_usbd_class_inst_t const * p_inst,
+                                    app_usbd_cdc_acm_user_event_t event)
+{
+    app_usbd_cdc_acm_t const * p_cdc_acm = app_usbd_cdc_acm_class_get(p_inst);
+
+    switch (event)
+    {
+        case APP_USBD_CDC_ACM_USER_EVT_PORT_OPEN:
+        {
+            //bsp_board_led_on(LED_CDC_ACM_OPEN);
+
+            /*Setup first transfer*/
+            ret_code_t ret = app_usbd_cdc_acm_read(&m_app_cdc_acm,
+                                                   m_rx_buffer,
+                                                   READ_SIZE);
+            UNUSED_VARIABLE(ret);
+            break;
+        }
+        case APP_USBD_CDC_ACM_USER_EVT_PORT_CLOSE:
+            //bsp_board_led_off(LED_CDC_ACM_OPEN);
+            break;
+        case APP_USBD_CDC_ACM_USER_EVT_TX_DONE:
+            //bsp_board_led_invert(LED_CDC_ACM_TX);
+            break;
+        case APP_USBD_CDC_ACM_USER_EVT_RX_DONE:
+        {
+            ret_code_t ret;
+            NRF_LOG_INFO("Bytes waiting: %d", app_usbd_cdc_acm_bytes_stored(p_cdc_acm));
+           
+            do
+            {
+                /*Get amount of data transfered*/
+                size_t size = app_usbd_cdc_acm_rx_size(p_cdc_acm);
+                NRF_LOG_INFO("RX: size: %lu char: %c", size, m_rx_buffer[0]);
+                KIMIA_USB_PRINT("Input:%c\r\n", m_rx_buffer[0]);
+
+                /* Fetch data until internal buffer is empty */
+                ret = app_usbd_cdc_acm_read(&m_app_cdc_acm,
+                                            m_rx_buffer,
+                                            READ_SIZE);
+            } while (ret == NRF_SUCCESS);
+
+
+//                static char m_tx_buffer[NRF_DRV_USBD_EPSIZE];
+//    size_t size = sprintf(m_tx_buffer, "LE KEK");
+//    app_usbd_cdc_acm_write(&m_app_cdc_acm, m_tx_buffer, size);
+
+            //bsp_board_led_invert(LED_CDC_ACM_RX);
+            break;
+        }
+        default:
+            break;
+    }
+}
+static void usbd_user_ev_handler(app_usbd_event_type_t event)
+{
+    switch (event)
+    {
+        case APP_USBD_EVT_DRV_SUSPEND:
+           // bsp_board_led_off(LED_USB_RESUME);
+            break;
+        case APP_USBD_EVT_DRV_RESUME:
+            //bsp_board_led_on(LED_USB_RESUME);
+            break;
+        case APP_USBD_EVT_STARTED:
+            break;
+        case APP_USBD_EVT_STOPPED:
+            app_usbd_disable();
+            //bsp_board_leds_off();
+            break;
+        case APP_USBD_EVT_POWER_DETECTED:
+            NRF_LOG_INFO("USB power detected");
+
+            if (!nrf_drv_usbd_is_enabled())
+            {
+                app_usbd_enable();
+            }
+            break;
+        case APP_USBD_EVT_POWER_REMOVED:
+            NRF_LOG_INFO("USB power removed");
+            app_usbd_stop();
+            break;
+        case APP_USBD_EVT_POWER_READY:
+            NRF_LOG_INFO("USB ready");
+            app_usbd_start();
+            break;
+        default:
+            break;
+    }
+}
+
+
+
+void kimia_usb_log_init()
+{
+    ret_code_t ret;
+    static const app_usbd_config_t usbd_config = {
+        .ev_state_proc = usbd_user_ev_handler
+    };
+    app_usbd_serial_num_generate();
+
+    ret = app_usbd_init(&usbd_config);
+    APP_ERROR_CHECK(ret);
+    //NRF_LOG_INFO("USBD CDC ACM example started.");
+
+    app_usbd_class_inst_t const * class_cdc_acm = app_usbd_cdc_acm_class_inst_get(&m_app_cdc_acm);
+    ret = app_usbd_class_append(class_cdc_acm);
+    APP_ERROR_CHECK(ret);
+
+
+    //power nie jest zaimplementowany
+
+//    if (USBD_POWER_DETECTION)
+//    {
+//        ret = app_usbd_power_events_enable();
+//        APP_ERROR_CHECK(ret);
+//    }
+//    else
+//    {
+//        NRF_LOG_INFO("No USB power detection enabled\r\nStarting USB now");
+//
+//        app_usbd_enable();
+//        app_usbd_start();
+//    }
+    app_usbd_enable();
+    app_usbd_start();
+
+}
+
+
+char* kimia_usb_log_get_txbuf()
+{
+    return m_tx_buffer;
+}
+
+#define EMERGENCY_TXT "kimia_usb_log_write() WARNING: String may be too long\r\n"
+void kimia_usb_log_write(char* tx,size_t size)
+{
+    //size_t size2=strnlen(tx,WRITE_SIZE);
+    if(size>=WRITE_SIZE-1){
+        //tekst większy lub równy buforowi
+        app_usbd_cdc_acm_write(&m_app_cdc_acm, EMERGENCY_TXT, sizeof(EMERGENCY_TXT));
+    }else{
+        app_usbd_cdc_acm_write(&m_app_cdc_acm, tx, size);
+    }
+    
+    
+    
+}
+
+
+bool kimia_usb_log_process()
+{
+    return app_usbd_event_queue_process();
+}
diff --git a/cw3_template/kimia_usb_log.h b/cw3_template/kimia_usb_log.h
new file mode 100644
index 0000000000000000000000000000000000000000..c440eb1acf8a0db02829f0d2383c3ff29f1750c0
--- /dev/null
+++ b/cw3_template/kimia_usb_log.h
@@ -0,0 +1,77 @@
+#ifndef KIMIA_USB_LOG__H__
+#define KIMIA_USB_LOG__H__
+
+#include "stdbool.h"
+#include "string.h"
+
+
+#ifndef USBD_POWER_DETECTION
+#define USBD_POWER_DETECTION false
+#endif
+
+#define READ_SIZE 1
+#define WRITE_SIZE 1000
+
+#define CDC_ACM_COMM_INTERFACE  0
+#define CDC_ACM_COMM_EPIN       NRF_DRV_USBD_EPIN2
+
+#define CDC_ACM_DATA_INTERFACE  1
+#define CDC_ACM_DATA_EPIN       NRF_DRV_USBD_EPIN1
+#define CDC_ACM_DATA_EPOUT      NRF_DRV_USBD_EPOUT1
+
+
+
+/**
+* To makro działa dokładnie jak printf, tyle że printuje na USB
+* 
+*/
+#define KIMIA_USB_PRINT( ...)  \
+    kimia_usb_log_write(kimia_usb_log_get_txbuf(),snprintf(kimia_usb_log_get_txbuf(),WRITE_SIZE, __VA_ARGS__) )
+
+
+
+
+/**
+* Inicjalizacja biblioteki
+*/
+void kimia_usb_log_init();
+
+/**
+* Funkcja zajmująca się obsługą procesu USB, pownna być dodana w funkcji idle_state_handle by wszystko działało
+*
+* @ret false jeśli nie ma żadnych eventów
+*/
+bool kimia_usb_log_process();
+
+/**
+* Zwraca statyczny bufor tx ukryty w pliku .c
+*/
+char* kimia_usb_log_get_txbuf();
+
+/**
+* Funkcja pomocnicza dla makra KIMIA_USB_PRINT
+* Używanie jej poza makrem będzie raczej uciążliwe
+*/
+void kimia_usb_log_write(char* tx,size_t size);
+
+/*
+$(SDKDIR)/components/libraries/usbd
+app_usbd.c
+app_usbd_core.c
+app_usbd_string_desc.c
+app_usbd_serial_num.c
+
+$(SDKDIR)/components/libraries/usbd/class/cdc/acm
+app_usbd_cdc_acm.c
+
+
+$(SDKDIR)/modules/nrfx/drivers/src
+nrfx_usbd.c
+nrfx_systick.c
+nrfx_power.c
+
+$(SDKDIR)/integration/nrfx/legacy
+nrf_drv_power.c
+*/
+
+#endif
\ No newline at end of file
diff --git a/cw3_template/main.c b/cw3_template/main.c
index 470f0d084bf483f3c4ff2bd7107cc3284759cb4a..9add47416399e1aafee8bde4b2c2bddbd83383e4 100644
--- a/cw3_template/main.c
+++ b/cw3_template/main.c
@@ -48,26 +48,31 @@
 #include "nrf_gpio.h"
 #include "nrf_delay.h"
 #include "nrf_drv_power.h"
+#include "nrfx_saadc.h"
 
 #include "app_error.h"
 
 #include "boards.h"
 #include "bsp.h"
-#include "usb.h"
-#include "app_timer.h"
 
-// NOTE: lab3
-#include "nrf_drv_gpiote.h"
+#include "nrf_pwr_mgmt.h"
+#include "nrf_drv_saadc.h"
+
 
-#define PIN_IN 20
 
-extern char m_rx_buffer[READ_SIZE];
-extern char m_tx_buffer[NRF_DRV_USBD_EPSIZE];
-extern bool usb_ready;
+#include "app_timer.h"
+#include "kimia_usb_log.h"
 
-extern app_usbd_cdc_acm_t m_app_cdc_acm;
 
 
+static void idle_state_handle(void)
+{
+    if (kimia_usb_log_process() == false)
+    {
+        nrf_pwr_mgmt_run();
+    }
+}
+
 static void init_bsp(void)
 {
     ret_code_t ret;
@@ -75,38 +80,32 @@ static void init_bsp(void)
     APP_ERROR_CHECK(ret);
 }
 
-static void usb_init(app_usbd_config_t usbd_config)
+
+
+
+
+void saadc_callback(nrf_drv_saadc_evt_t const * p_event)
 {
-    ret_code_t ret;
-    
-    app_usbd_serial_num_generate();
+    //empty callback
+}
 
-    ret = app_usbd_init(&usbd_config);
-    APP_ERROR_CHECK(ret);
 
-    app_usbd_class_inst_t const * class_cdc_acm = app_usbd_cdc_acm_class_inst_get(&m_app_cdc_acm);
-    ret = app_usbd_class_append(class_cdc_acm);
-    APP_ERROR_CHECK(ret);
+void saadc_init(void)
+{
+    ret_code_t err_code;
+
+    err_code = nrf_drv_saadc_init(NULL, saadc_callback);
+    APP_ERROR_CHECK(err_code);
 
-    if (USBD_POWER_DETECTION)
-    {
-        ret = app_usbd_power_events_enable();
-        APP_ERROR_CHECK(ret);
-    }
-    else
-    {
-        app_usbd_enable();
-        app_usbd_start();
-    }
 }
 
 
+
+
 int main(void)
 {
     ret_code_t ret;
-    static const app_usbd_config_t usbd_config = {
-        .ev_state_proc = usbd_user_ev_handler
-    };
+
 
     ret = nrf_drv_clock_init();
     APP_ERROR_CHECK(ret);
@@ -118,34 +117,16 @@ int main(void)
         /* Just waiting */
     }
 
-    ret = app_timer_init();
-    APP_ERROR_CHECK(ret);
-
-    usb_init(usbd_config);
+    kimia_usb_log_init();
     init_bsp();
+    saadc_init();
+    
+    KIMIA_USB_PRINT("LAB3."); //print do usb zadziała tylko po jakimś czasie, użyjcie tej funkcji w timerze
     
-    bsp_board_led_on(BSP_BOARD_LED_0);
-
-    bool msg_sent = 0;
 
-    while (true)
+    //Dont change this loop
+    for (;;)
     {
-
-        while (app_usbd_event_queue_process())
-        {
-            /* Nothing to do */
-        }
-
-        if (usb_ready && !msg_sent)
-        {
-            size_t size = sprintf(m_tx_buffer, "Systemy wbudowane i mikrokontrolery!\r\n");
-            app_usbd_cdc_acm_write(&m_app_cdc_acm, m_tx_buffer, size);
-            msg_sent = 1;
-        }
-
-        /* Sleep CPU only if there was no interrupt since last loop processing */
-        __WFE();
+         idle_state_handle();
     }
 }
-
-/** @} */
diff --git a/cw3_template/pca10059/s140/armgcc/Makefile b/cw3_template/pca10059/s140/armgcc/Makefile
index 53157c2e489139c29fb5c8d3cb9ebffcd934e37e..ff5018fdcea360e811e11fc101fb9d27c209c07b 100644
--- a/cw3_template/pca10059/s140/armgcc/Makefile
+++ b/cw3_template/pca10059/s140/armgcc/Makefile
@@ -2,7 +2,7 @@ PROJECT_NAME     := usbd_cdc_acm_pca10056
 TARGETS          := nrf52840_xxaa
 OUTPUT_DIRECTORY := _build
 
-SDK_ROOT := ../../../../../..
+SDK_ROOT := /home/td/Desktop/KODY/sdk_nor/nRF5SDK160098a08e2
 PROJ_DIR := ../../..
 
 $(OUTPUT_DIRECTORY)/nrf52840_xxaa.out: \
@@ -68,12 +68,13 @@ SRC_FILES += \
   $(SDK_ROOT)/components/libraries/bsp/bsp.c \
   $(SDK_ROOT)/components/libraries/bsp/bsp_cli.c \
   $(PROJ_DIR)/main.c \
-  $(PROJ_DIR)/usb.c \
   $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT.c \
   $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT_Syscalls_GCC.c \
   $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT_printf.c \
   $(SDK_ROOT)/modules/nrfx/mdk/system_nrf52840.c \
   $(SDK_ROOT)/external/utf_converter/utf.c \
+  $(PROJ_DIR)/kimia_usb_log.c \
+  $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_saadc.c \
 
 # Include folders common to all targets
 INC_FOLDERS += \
@@ -140,7 +141,7 @@ CFLAGS += -DFLOAT_ABI_HARD
 CFLAGS += -DNRF52840_XXAA
 CFLAGS += -mcpu=cortex-m4
 CFLAGS += -mthumb -mabi=aapcs
-CFLAGS += -Wall -Werror
+#CFLAGS += -Wall -Werror
 CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
 # keep every function in a separate section, this allows linker to discard unused ones
 CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
diff --git a/cw3_template/pca10059/s140/armgcc/_build/nrf52840_xxaa.bin b/cw3_template/pca10059/s140/armgcc/_build/nrf52840_xxaa.bin
deleted file mode 100755
index 81fb90d32afef69f288bcfac932d887d15a8fe81..0000000000000000000000000000000000000000
Binary files a/cw3_template/pca10059/s140/armgcc/_build/nrf52840_xxaa.bin and /dev/null differ
diff --git a/cw3_template/pca10059/s140/armgcc/_build/nrf52840_xxaa.in b/cw3_template/pca10059/s140/armgcc/_build/nrf52840_xxaa.in
deleted file mode 100644
index 913ec2fdc902ac69cb3f05005ace9ad66ff8565c..0000000000000000000000000000000000000000
--- a/cw3_template/pca10059/s140/armgcc/_build/nrf52840_xxaa.in
+++ /dev/null
@@ -1 +0,0 @@
-_build/nrf52840_xxaa/gcc_startup_nrf52840.S.o _build/nrf52840_xxaa/nrf_log_backend_rtt.c.o _build/nrf52840_xxaa/nrf_log_backend_serial.c.o _build/nrf52840_xxaa/nrf_log_backend_uart.c.o _build/nrf52840_xxaa/nrf_log_default_backends.c.o _build/nrf52840_xxaa/nrf_log_frontend.c.o _build/nrf52840_xxaa/nrf_log_str_formatter.c.o _build/nrf52840_xxaa/boards.c.o _build/nrf52840_xxaa/app_button.c.o _build/nrf52840_xxaa/app_error.c.o _build/nrf52840_xxaa/app_error_handler_gcc.c.o _build/nrf52840_xxaa/app_error_weak.c.o _build/nrf52840_xxaa/app_fifo.c.o _build/nrf52840_xxaa/app_scheduler.c.o _build/nrf52840_xxaa/app_timer2.c.o _build/nrf52840_xxaa/app_uart_fifo.c.o _build/nrf52840_xxaa/app_usbd.c.o _build/nrf52840_xxaa/app_usbd_cdc_acm.c.o _build/nrf52840_xxaa/app_usbd_core.c.o _build/nrf52840_xxaa/app_usbd_serial_num.c.o _build/nrf52840_xxaa/app_usbd_string_desc.c.o _build/nrf52840_xxaa/app_util_platform.c.o _build/nrf52840_xxaa/drv_rtc.c.o _build/nrf52840_xxaa/fnmatch.c.o _build/nrf52840_xxaa/hardfault_handler_gcc.c.o _build/nrf52840_xxaa/hardfault_implementation.c.o _build/nrf52840_xxaa/nrf_assert.c.o _build/nrf52840_xxaa/nrf_atfifo.c.o _build/nrf52840_xxaa/nrf_atomic.c.o _build/nrf52840_xxaa/nrf_balloc.c.o _build/nrf52840_xxaa/nrf_cli.c.o _build/nrf52840_xxaa/nrf_cli_uart.c.o _build/nrf52840_xxaa/nrf_fprintf.c.o _build/nrf52840_xxaa/nrf_fprintf_format.c.o _build/nrf52840_xxaa/nrf_memobj.c.o _build/nrf52840_xxaa/nrf_pwr_mgmt.c.o _build/nrf52840_xxaa/nrf_queue.c.o _build/nrf52840_xxaa/nrf_ringbuf.c.o _build/nrf52840_xxaa/nrf_section_iter.c.o _build/nrf52840_xxaa/nrf_sortlist.c.o _build/nrf52840_xxaa/nrf_strerror.c.o _build/nrf52840_xxaa/nrf_drv_clock.c.o _build/nrf52840_xxaa/nrf_drv_power.c.o _build/nrf52840_xxaa/nrf_drv_uart.c.o _build/nrf52840_xxaa/nrf_nvic.c.o _build/nrf52840_xxaa/nrf_soc.c.o _build/nrf52840_xxaa/nrfx_atomic.c.o _build/nrf52840_xxaa/nrfx_clock.c.o _build/nrf52840_xxaa/nrfx_gpiote.c.o _build/nrf52840_xxaa/nrfx_power.c.o _build/nrf52840_xxaa/nrfx_prs.c.o _build/nrf52840_xxaa/nrfx_systick.c.o _build/nrf52840_xxaa/nrfx_uart.c.o _build/nrf52840_xxaa/nrfx_uarte.c.o _build/nrf52840_xxaa/nrfx_usbd.c.o _build/nrf52840_xxaa/bsp.c.o _build/nrf52840_xxaa/bsp_cli.c.o _build/nrf52840_xxaa/main.c.o _build/nrf52840_xxaa/usb.c.o _build/nrf52840_xxaa/SEGGER_RTT.c.o _build/nrf52840_xxaa/SEGGER_RTT_Syscalls_GCC.c.o _build/nrf52840_xxaa/SEGGER_RTT_printf.c.o _build/nrf52840_xxaa/system_nrf52840.c.o _build/nrf52840_xxaa/utf.c.o  -lc -lnosys -lm
diff --git a/cw3_template/pca10059/s140/config/sdk_config.h b/cw3_template/pca10059/s140/config/sdk_config.h
index d6b19ce53d88283ae7cc6a7697ebab052c013570..2c93a149ffb49dda13cfb4371547890c9f505e80 100644
--- a/cw3_template/pca10059/s140/config/sdk_config.h
+++ b/cw3_template/pca10059/s140/config/sdk_config.h
@@ -48,6 +48,173 @@
 #endif
 // <h> nRF_Drivers 
 
+// <e> NRFX_SAADC_ENABLED - nrfx_saadc - SAADC peripheral driver
+//==========================================================
+#ifndef NRFX_SAADC_ENABLED
+#define NRFX_SAADC_ENABLED 1
+#endif
+// <o> NRFX_SAADC_CONFIG_RESOLUTION  - Resolution
+ 
+// <0=> 8 bit 
+// <1=> 10 bit 
+// <2=> 12 bit 
+// <3=> 14 bit 
+
+#ifndef NRFX_SAADC_CONFIG_RESOLUTION
+#define NRFX_SAADC_CONFIG_RESOLUTION 1
+#endif
+
+// <o> NRFX_SAADC_CONFIG_OVERSAMPLE  - Sample period
+ 
+// <0=> Disabled 
+// <1=> 2x 
+// <2=> 4x 
+// <3=> 8x 
+// <4=> 16x 
+// <5=> 32x 
+// <6=> 64x 
+// <7=> 128x 
+// <8=> 256x 
+
+#ifndef NRFX_SAADC_CONFIG_OVERSAMPLE
+#define NRFX_SAADC_CONFIG_OVERSAMPLE 0
+#endif
+
+// <q> NRFX_SAADC_CONFIG_LP_MODE  - Enabling low power mode
+ 
+
+#ifndef NRFX_SAADC_CONFIG_LP_MODE
+#define NRFX_SAADC_CONFIG_LP_MODE 0
+#endif
+
+// <o> NRFX_SAADC_CONFIG_IRQ_PRIORITY  - Interrupt priority
+ 
+// <0=> 0 (highest) 
+// <1=> 1 
+// <2=> 2 
+// <3=> 3 
+// <4=> 4 
+// <5=> 5 
+// <6=> 6 
+// <7=> 7 
+
+#ifndef NRFX_SAADC_CONFIG_IRQ_PRIORITY
+#define NRFX_SAADC_CONFIG_IRQ_PRIORITY 6
+#endif
+
+// <e> NRFX_SAADC_CONFIG_LOG_ENABLED - Enables logging in the module.
+//==========================================================
+#ifndef NRFX_SAADC_CONFIG_LOG_ENABLED
+#define NRFX_SAADC_CONFIG_LOG_ENABLED 0
+#endif
+// <o> NRFX_SAADC_CONFIG_LOG_LEVEL  - Default Severity level
+ 
+// <0=> Off 
+// <1=> Error 
+// <2=> Warning 
+// <3=> Info 
+// <4=> Debug 
+
+#ifndef NRFX_SAADC_CONFIG_LOG_LEVEL
+#define NRFX_SAADC_CONFIG_LOG_LEVEL 3
+#endif
+
+// <o> NRFX_SAADC_CONFIG_INFO_COLOR  - ANSI escape code prefix.
+ 
+// <0=> Default 
+// <1=> Black 
+// <2=> Red 
+// <3=> Green 
+// <4=> Yellow 
+// <5=> Blue 
+// <6=> Magenta 
+// <7=> Cyan 
+// <8=> White 
+
+#ifndef NRFX_SAADC_CONFIG_INFO_COLOR
+#define NRFX_SAADC_CONFIG_INFO_COLOR 0
+#endif
+
+// <o> NRFX_SAADC_CONFIG_DEBUG_COLOR  - ANSI escape code prefix.
+ 
+// <0=> Default 
+// <1=> Black 
+// <2=> Red 
+// <3=> Green 
+// <4=> Yellow 
+// <5=> Blue 
+// <6=> Magenta 
+// <7=> Cyan 
+// <8=> White 
+
+#ifndef NRFX_SAADC_CONFIG_DEBUG_COLOR
+#define NRFX_SAADC_CONFIG_DEBUG_COLOR 0
+#endif
+
+// </e>
+
+// </e>
+
+
+// <e> SAADC_ENABLED - nrf_drv_saadc - SAADC peripheral driver - legacy layer
+//==========================================================
+#ifndef SAADC_ENABLED
+#define SAADC_ENABLED 1
+#endif
+// <o> SAADC_CONFIG_RESOLUTION  - Resolution
+ 
+// <0=> 8 bit 
+// <1=> 10 bit 
+// <2=> 12 bit 
+// <3=> 14 bit 
+
+#ifndef SAADC_CONFIG_RESOLUTION
+#define SAADC_CONFIG_RESOLUTION 1
+#endif
+
+// <o> SAADC_CONFIG_OVERSAMPLE  - Sample period
+ 
+// <0=> Disabled 
+// <1=> 2x 
+// <2=> 4x 
+// <3=> 8x 
+// <4=> 16x 
+// <5=> 32x 
+// <6=> 64x 
+// <7=> 128x 
+// <8=> 256x 
+
+#ifndef SAADC_CONFIG_OVERSAMPLE
+#define SAADC_CONFIG_OVERSAMPLE 0
+#endif
+
+// <q> SAADC_CONFIG_LP_MODE  - Enabling low power mode
+ 
+
+#ifndef SAADC_CONFIG_LP_MODE
+#define SAADC_CONFIG_LP_MODE 0
+#endif
+
+// <o> SAADC_CONFIG_IRQ_PRIORITY  - Interrupt priority
+ 
+
+// <i> Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
+// <0=> 0 (highest) 
+// <1=> 1 
+// <2=> 2 
+// <3=> 3 
+// <4=> 4 
+// <5=> 5 
+// <6=> 6 
+// <7=> 7 
+
+#ifndef SAADC_CONFIG_IRQ_PRIORITY
+#define SAADC_CONFIG_IRQ_PRIORITY 6
+#endif
+
+// </e>
+
+
 //==========================================================
 // <e> GPIOTE_ENABLED - nrf_drv_gpiote - GPIOTE peripheral driver - legacy layer
 //==========================================================
@@ -1760,7 +1927,7 @@
 // <e> NRF_LOG_BACKEND_RTT_ENABLED - nrf_log_backend_rtt - Log RTT backend
 //==========================================================
 #ifndef NRF_LOG_BACKEND_RTT_ENABLED
-#define NRF_LOG_BACKEND_RTT_ENABLED 0
+#define NRF_LOG_BACKEND_RTT_ENABLED 1
 #endif
 // <o> NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. 
 // <i> Size of the buffer is a trade-off between RAM usage and processing.
diff --git a/cw3_template/temperature.c b/cw3_template/temperature.c
deleted file mode 100644
index 1d29a2380b4582436ac77f185389f49ef0e41714..0000000000000000000000000000000000000000
--- a/cw3_template/temperature.c
+++ /dev/null
@@ -1,25 +0,0 @@
-#include "temperature.h"
-
-int32_t get_temperature(void)
-{
-    // This function contains workaround for PAN_028 rev2.0A anomalies 28, 29,30 and 31.
-    int32_t volatile temp;
-    
-    NRF_TEMP->TASKS_START = 1; /** Start the temperature measurement. */
-
-    /* Busy wait while temperature measurement is not finished, you can skip waiting if you enable interrupt for DATARDY event and read the result in the interrupt. */
-    /*lint -e{845} // A zero has been given as right argument to operator '|'" */
-    while (NRF_TEMP->EVENTS_DATARDY == 0)
-    {
-        // Do nothing.
-    }
-    NRF_TEMP->EVENTS_DATARDY = 0;
-
-    /**@note Workaround for PAN_028 rev2.0A anomaly 29 - TEMP: Stop task clears the TEMP register. */
-    temp = (nrf_temp_read() / 4);
-
-    /**@note Workaround for PAN_028 rev2.0A anomaly 30 - TEMP: Temp module analog front end does not power down when DATARDY event occurs. */
-    NRF_TEMP->TASKS_STOP = 1; /** Stop the temperature measurement. */
-
-    return temp;
-}
\ No newline at end of file
diff --git a/cw3_template/temperature.h b/cw3_template/temperature.h
deleted file mode 100644
index 20896e0d5223170b3cb8a3d686f83061ae4da159..0000000000000000000000000000000000000000
--- a/cw3_template/temperature.h
+++ /dev/null
@@ -1,4 +0,0 @@
-#include <stdint.h>
-#include "nrf_temp.h"
-
-int32_t get_temperature(void);
\ No newline at end of file
diff --git a/cw3_template/usb.c b/cw3_template/usb.c
deleted file mode 100644
index c9d64c45dd8d6863fccb07df90ebdaecd639fc21..0000000000000000000000000000000000000000
--- a/cw3_template/usb.c
+++ /dev/null
@@ -1,119 +0,0 @@
-#include "usb.h"
-#include "app_timer.h"
-
-char m_rx_buffer[READ_SIZE];
-char m_tx_buffer[NRF_DRV_USBD_EPSIZE];
-volatile bool usb_ready = 0;
-
-APP_TIMER_DEF(m_usb_timer);
-
-/**
- * @brief CDC_ACM class instance
- * */
-APP_USBD_CDC_ACM_GLOBAL_DEF(m_app_cdc_acm,
-                            cdc_acm_user_ev_handler,
-                            CDC_ACM_COMM_INTERFACE,
-                            CDC_ACM_DATA_INTERFACE,
-                            CDC_ACM_COMM_EPIN,
-                            CDC_ACM_DATA_EPIN,
-                            CDC_ACM_DATA_EPOUT,
-                            APP_USBD_CDC_COMM_PROTOCOL_AT_V250
-);
-
-static void usb_timer_handler(void* p_context)
-{
-    usb_ready = 1;
-}
-
-
-/**
- * @brief User event handler @ref app_usbd_cdc_acm_user_ev_handler_t (headphones)
- * */
-void cdc_acm_user_ev_handler(app_usbd_class_inst_t const * p_inst,
-                                    app_usbd_cdc_acm_user_event_t event)
-{
-    app_usbd_cdc_acm_t const * p_cdc_acm = app_usbd_cdc_acm_class_get(p_inst);
-
-    switch (event)
-    {
-        case APP_USBD_CDC_ACM_USER_EVT_PORT_OPEN:
-        {
-            //bsp_board_led_on(LED_CDC_ACM_OPEN);
-
-            /*Setup first transfer*/
-            ret_code_t ret = app_usbd_cdc_acm_read(&m_app_cdc_acm,
-                                                   m_rx_buffer,
-                                                   READ_SIZE);
-            UNUSED_VARIABLE(ret);
-            ret = app_timer_create(&m_usb_timer, APP_TIMER_MODE_SINGLE_SHOT, usb_timer_handler);
-            APP_ERROR_CHECK(ret);
-            ret = app_timer_start(m_usb_timer, APP_TIMER_TICKS(50), 0);
-            APP_ERROR_CHECK(ret);
-           break;
-        }
-        case APP_USBD_CDC_ACM_USER_EVT_PORT_CLOSE:
-            //bsp_board_led_off(LED_CDC_ACM_OPEN);
-            break;
-        case APP_USBD_CDC_ACM_USER_EVT_TX_DONE:
-            //bsp_board_led_invert(LED_CDC_ACM_TX);
-            break;
-        case APP_USBD_CDC_ACM_USER_EVT_RX_DONE:
-        {
-            ret_code_t ret;
-            //NRF_LOG_INFO("Bytes waiting: %d", app_usbd_cdc_acm_bytes_stored(p_cdc_acm));
-            do
-            {
-                /*Get amount of data transfered*/
-                app_usbd_cdc_acm_rx_size(p_cdc_acm);
-                //NRF_LOG_INFO("RX: size: %lu char: %c", size, m_rx_buffer[0]);
-
-                /* Fetch data until internal buffer is empty */
-                ret = app_usbd_cdc_acm_read(&m_app_cdc_acm,
-                                            m_rx_buffer,
-                                            READ_SIZE);
-            } while (ret == NRF_SUCCESS);
-
-            //bsp_board_led_invert(LED_CDC_ACM_RX);
-            break;
-        }
-        default:
-            break;
-    }
-}
-
-void usbd_user_ev_handler(app_usbd_event_type_t event)
-{
-    switch (event)
-    {
-        case APP_USBD_EVT_DRV_SUSPEND:
-            //bsp_board_led_off(LED_USB_RESUME);
-            break;
-        case APP_USBD_EVT_DRV_RESUME:
-            //bsp_board_led_on(LED_USB_RESUME);
-            break;
-        case APP_USBD_EVT_STARTED:
-            break;
-        case APP_USBD_EVT_STOPPED:
-            app_usbd_disable();
-            //bsp_board_leds_off();
-            break;
-        case APP_USBD_EVT_POWER_DETECTED:
-           // NRF_LOG_INFO("USB power detected");
-
-            if (!nrf_drv_usbd_is_enabled())
-            {
-                app_usbd_enable();
-            }
-            break;
-        case APP_USBD_EVT_POWER_REMOVED:
-            //NRF_LOG_INFO("USB power removed");
-            app_usbd_stop();
-            break;
-        case APP_USBD_EVT_POWER_READY:
-            //NRF_LOG_INFO("USB ready");
-            app_usbd_start();
-            break;
-        default:
-            break;
-    }
-}
\ No newline at end of file
diff --git a/cw3_template/usb.h b/cw3_template/usb.h
deleted file mode 100644
index 091f472541cc43eea1946b07901f27fd501e5aef..0000000000000000000000000000000000000000
--- a/cw3_template/usb.h
+++ /dev/null
@@ -1,48 +0,0 @@
-#include "app_util.h"
-#include "app_usbd_core.h"
-#include "app_usbd.h"
-#include "app_usbd_string_desc.h"
-#include "app_usbd_cdc_acm.h"
-#include "app_usbd_serial_num.h"
-#include "nrf_delay.h"
-
-
-/**
- * @brief Enable power USB detection
- *
- * Configure if example supports USB port connection
- */
-#ifndef USBD_POWER_DETECTION
-#define USBD_POWER_DETECTION true
-#endif
-
-#define READ_SIZE 1
-
-
-
-
-void cdc_acm_user_ev_handler(app_usbd_class_inst_t const * p_inst,
-                                    app_usbd_cdc_acm_user_event_t event);
-
-void usbd_user_ev_handler(app_usbd_event_type_t event);
-
-#define CDC_ACM_COMM_INTERFACE  0
-#define CDC_ACM_COMM_EPIN       NRF_DRV_USBD_EPIN2
-
-#define CDC_ACM_DATA_INTERFACE  1
-#define CDC_ACM_DATA_EPIN       NRF_DRV_USBD_EPIN1
-#define CDC_ACM_DATA_EPOUT      NRF_DRV_USBD_EPOUT1
-
-
-///**
-// * @brief CDC_ACM class instance
-// * */
-//APP_USBD_CDC_ACM_GLOBAL_DEF(m_app_cdc_acm,
-//                            cdc_acm_user_ev_handler,
-//                            CDC_ACM_COMM_INTERFACE,
-//                            CDC_ACM_DATA_INTERFACE,
-//                            CDC_ACM_COMM_EPIN,
-//                            CDC_ACM_DATA_EPIN,
-//                            CDC_ACM_DATA_EPOUT,
-//                            APP_USBD_CDC_COMM_PROTOCOL_AT_V250
-//);
\ No newline at end of file